blob: 9b5e587f2ce1cf8c77fc04a2f16edd33418d56db (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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())
}
}
|