diff options
Diffstat (limited to 'SolverVTests/Utilities/AppGroupManagerTests.swift')
| -rw-r--r-- | SolverVTests/Utilities/AppGroupManagerTests.swift | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/SolverVTests/Utilities/AppGroupManagerTests.swift b/SolverVTests/Utilities/AppGroupManagerTests.swift new file mode 100644 index 0000000..9b5e587 --- /dev/null +++ b/SolverVTests/Utilities/AppGroupManagerTests.swift @@ -0,0 +1,58 @@ +import XCTest +@testable import Solverv + +final class AppGroupManagerTests: XCTestCase { + var manager: AppGroupManager! + + override func setUp() { + super.setUp() + manager = AppGroupManager() + manager.clearAllData() + } + + override func tearDown() { + super.tearDown() + manager.clearAllData() + } + + func testSaveAndRetrieveLocation() { + let location = AppGroupManager.UserLocation( + latitude: 59.9139, + longitude: 10.7522, + timestamp: "2026-03-23T10:00:00Z", + isDefaultLocation: false + ) + + manager.saveLocation(location) + let retrieved = manager.getLocation() + + XCTAssertNotNil(retrieved) + XCTAssertEqual(retrieved?.latitude, 59.9139) + XCTAssertEqual(retrieved?.longitude, 10.7522) + } + + func testSaveAndRetrieveSunTimes() { + let sunTimes = AppGroupManager.SunTimes( + date: "2026-03-20", + sunrise: "2026-03-20T06:42:00", + sunset: "2026-03-20T18:15:00", + timestamp: "2026-03-23T10:00:00Z" + ) + + manager.saveSunTimes(sunTimes) + let retrieved = manager.getSunTimes() + + XCTAssertNotNil(retrieved) + XCTAssertEqual(retrieved?.date, "2026-03-20") + } + + func testClearData() { + let location = AppGroupManager.UserLocation( + latitude: 0.0, longitude: 0.0, timestamp: "2026-03-23T10:00:00Z", isDefaultLocation: true + ) + manager.saveLocation(location) + manager.clearAllData() + + XCTAssertNil(manager.getLocation()) + } +} |
