Add test cases for repository instantiation cases

This commit is contained in:
davidoskky 2022-09-27 23:16:30 +02:00
parent e2afff0b8e
commit 41c951b659

View File

@ -45,7 +45,14 @@ class RepositoryTest() {
@Test @Test
fun `Instantiate repository`() { fun `Instantiate repository`() {
val repository = Repository(api, appSettingsService, connectivityStatus, db) val success = try {
Repository(api, appSettingsService, connectivityStatus, db)
true
} catch (e: Exception) {
false
}
assertEquals(true, success)
} }
@Test @Test
@ -53,14 +60,28 @@ class RepositoryTest() {
every { appSettingsService.getApiVersion() } returns -1 every { appSettingsService.getApiVersion() } returns -1
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
val repository = Repository(api, appSettingsService, connectivityStatus, db) val success = try {
Repository(api, appSettingsService, connectivityStatus, db)
true
} catch (e: Exception) {
false
}
assertEquals(true, success)
} }
@Test @Test
fun `Instantiate repository with negative stats`() { fun `Instantiate repository with negative stats`() {
coEvery { api.stats() } returns SelfossModel.StatusAndData(success = true, data = SelfossModel.Stats(-100, -50, -20)) coEvery { api.stats() } returns SelfossModel.StatusAndData(success = true, data = SelfossModel.Stats(-100, -50, -20))
val repository = Repository(api, appSettingsService, connectivityStatus, db) val success = try {
Repository(api, appSettingsService, connectivityStatus, db)
true
} catch (e: Exception) {
false
}
assertEquals(true, success)
} }
@Test @Test