1
1
/*
2
- * Copyright (C) 2022, 2023 Axel Paetzold
2
+ * Copyright (C) 2022, 2023, 2025 Axel Paetzold
3
3
*
4
4
* This program is free software: you can redistribute it and/or modify
5
5
* it under the terms of the GNU General Public License as published by
@@ -27,7 +27,6 @@ import com.yacgroup.yacguide.database.TestDB.Companion.INVALID_NAME
27
27
import com.yacgroup.yacguide.database.TestDB.Companion.REGIONS
28
28
import com.yacgroup.yacguide.database.TestDB.Companion.ROUTES
29
29
import com.yacgroup.yacguide.database.TestDB.Companion.SECTORS
30
- import kotlinx.coroutines.ExperimentalCoroutinesApi
31
30
import kotlinx.coroutines.test.runTest
32
31
import org.junit.jupiter.api.*
33
32
import org.junit.jupiter.api.Assertions.*
@@ -58,19 +57,16 @@ class RegionDaoTests {
58
57
_db .close()
59
58
}
60
59
61
- @OptIn(ExperimentalCoroutinesApi ::class )
62
60
@Test
63
61
fun getAllInCountry_invalidCountryName_returnsEmptyList () = runTest {
64
62
assertTrue(_regionDao .getAllInCountry(INVALID_NAME ).isEmpty())
65
63
}
66
64
67
- @OptIn(ExperimentalCoroutinesApi ::class )
68
65
@Test
69
66
fun getAllInCountry_noRegionsAvailable_returnsEmptyList () = runTest {
70
67
assertTrue(_regionDao .getAllInCountry(COUNTRIES .last().name).isEmpty())
71
68
}
72
69
73
- @OptIn(ExperimentalCoroutinesApi ::class )
74
70
@Test
75
71
fun getAllInCountry_regionsAvailable_returnsCorrespondingRegions () = runTest {
76
72
val country1Name = COUNTRIES .first().name
@@ -80,7 +76,6 @@ class RegionDaoTests {
80
76
assertTrue(equal(regionsInCountry1, _regionDao .getAllInCountry(country1Name)))
81
77
}
82
78
83
- @OptIn(ExperimentalCoroutinesApi ::class )
84
79
@Test
85
80
fun getAllNonEmpty_sectorsWithParentRegionsAvailable_returnsCorrespondingRegions () = runTest {
86
81
val nonEmptyRegions = REGIONS .filter { region ->
@@ -89,26 +84,22 @@ class RegionDaoTests {
89
84
assertTrue(equal(nonEmptyRegions, _regionDao .getAllNonEmpty()))
90
85
}
91
86
92
- @OptIn(ExperimentalCoroutinesApi ::class )
93
87
@Test
94
88
fun getRegion_invalidRegionId_returnsNull () = runTest {
95
89
assertNull(_regionDao .getRegion(INVALID_ID ))
96
90
}
97
91
98
- @OptIn(ExperimentalCoroutinesApi ::class )
99
92
@Test
100
93
fun getRegion_regionAvailable_returnsRegion () = runTest {
101
94
val region = REGIONS .first()
102
95
assertEquals(_regionDao .getRegion(region.id), region)
103
96
}
104
97
105
- @OptIn(ExperimentalCoroutinesApi ::class )
106
98
@Test
107
99
fun getRegionForRoute_invalidRouteId_returnsNull () = runTest {
108
100
assertNull(_regionDao .getRegionForRoute(INVALID_ID ))
109
101
}
110
102
111
- @OptIn(ExperimentalCoroutinesApi ::class )
112
103
@Test
113
104
fun getRegionForRoute_regionForRouteAvailable_returnsAccordingRegion () = runTest {
114
105
val region = REGIONS .first()
@@ -147,24 +138,10 @@ class RegionDaoDeletionTests {
147
138
_db .close()
148
139
}
149
140
150
-
151
- @OptIn(ExperimentalCoroutinesApi ::class )
152
141
@Test
153
142
fun deleteAll_regionTableBecomesEmpty () = runTest {
154
143
_regionDao .deleteAll()
155
144
assertTrue(_regionDao .all.isEmpty())
156
145
}
157
146
158
- @OptIn(ExperimentalCoroutinesApi ::class )
159
- @Test
160
- fun deleteAll_countryNameGiven_regionTableDoesNotContainCorrespondingRegionsAnymore () = runTest {
161
- val country1Name = COUNTRIES .first().name
162
- val regionsInCountry1 = REGIONS .filter {
163
- it.country == country1Name
164
- }
165
- _regionDao .deleteAll(country1Name)
166
- regionsInCountry1.forEach {
167
- assertFalse(_regionDao .all.contains(it))
168
- }
169
- }
170
147
}
0 commit comments