-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use states and events in PersonDetails
- Loading branch information
Showing
8 changed files
with
273 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
app/src/androidTest/java/com/example/rememberme/data/repository/PeopleRepositoryImplTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
//package com.example.rememberme.data.repository | ||
// | ||
//import com.example.rememberme.R | ||
//import com.example.rememberme.data.PeopleRepositoryImpl | ||
//import com.example.rememberme.domain.model.People | ||
//import com.example.remindme.database.PeopleDao | ||
//import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
//import kotlinx.coroutines.test.runTest | ||
//import org.junit.Assert.assertEquals | ||
//import org.junit.Before | ||
//import org.junit.Test | ||
//import org.mockito.MockitoAnnotations | ||
//import javax.inject.Inject | ||
// | ||
//@ExperimentalCoroutinesApi | ||
//class PeopleRepositoryImplTest { | ||
// | ||
// @Inject | ||
// private lateinit var peopleDao: PeopleDao | ||
// | ||
// private lateinit var peopleRepository: PeopleRepositoryImpl | ||
// | ||
// @Before | ||
// fun setUp() { | ||
// MockitoAnnotations.initMocks(this::class) | ||
// peopleRepository = PeopleRepositoryImpl(peopleDao) | ||
// } | ||
// | ||
// @Test | ||
// fun getAllPeopleShouldReturnListOfPeople() = runTest { | ||
// // Arrange | ||
// val peopleList = listOf( | ||
// People( | ||
// 1, "John", secondName = "Doe", place = "", time = "", gender = "",avatar= R.drawable.ic_m3,), | ||
// People(1, "John", secondName = "Doe", place = "", time = "", gender = "",avatar= R.drawable.ic_m3,) | ||
// ) | ||
// peopleRepository.insertPeople(peopleList[0]) | ||
// peopleRepository.insertPeople(peopleList[1]) | ||
// | ||
// // Act | ||
// val result = peopleRepository.getAllPeople() | ||
// | ||
// // Assert | ||
// result.collect { | ||
// assertEquals(peopleList, it) | ||
// } | ||
// } | ||
// | ||
//// @Test | ||
//// fun insertPeopleShouldCallInsertPeopleOnDao() = runBlocking { | ||
//// // Arrange | ||
//// val person = People(1, "John", secondName = "Doe", place = "", time = "", gender = "",avatar= R.drawable.ic_m3,) | ||
//// | ||
//// // Act | ||
//// peopleRepository.insertPeople(person) | ||
//// | ||
//// // Assert | ||
//// Mockito.verify(peopleDao, Mockito.times(1)).insertPeople(person) | ||
//// } | ||
//// | ||
//// @Test | ||
//// fun `deletePeople should call deletePeople on dao`() = runBlocking { | ||
//// // Arrange | ||
//// val person = People(1, "John", secondName = "Doe", place = "", time = "", gender = "",avatar= R.drawable.ic_m3,) | ||
//// | ||
//// // Act | ||
//// peopleRepository.deletePeople(person) | ||
//// | ||
//// // Assert | ||
//// Mockito.verify(peopleDao, Mockito.times(1)).deletePeople(person) | ||
//// } | ||
//// | ||
//// @Test | ||
//// fun `updatePeople should call updatePeople on dao`() = runBlocking { | ||
//// // Arrange | ||
//// val person = People(1, "John Doe") | ||
//// | ||
//// // Act | ||
//// peopleRepository.updatePeople(person) | ||
//// | ||
//// // Assert | ||
//// Mockito.verify(peopleDao, Mockito.times(1)).updatePeople(person) | ||
//// } | ||
//// | ||
//// @Test | ||
//// fun `deleteAllPeople should call deleteAllPeople on dao`() = runBlocking { | ||
//// // Act | ||
//// peopleRepository.deleteAllPeople() | ||
//// | ||
//// // Assert | ||
//// Mockito.verify(peopleDao, Mockito.times(1)).deleteAllPeople() | ||
//// } | ||
//// | ||
//// @Test | ||
//// fun `getPeopleById should return person`() = runBlocking { | ||
//// // Arrange | ||
//// val person = People(1, "John Doe") | ||
//// Mockito.`when`(peopleDao.getPeopleById(1)).thenReturn(person) | ||
//// | ||
//// // Act | ||
//// val result = peopleRepository.getPeopleById(1) | ||
//// | ||
//// // Assert | ||
//// assertEquals(person, result) | ||
//// } | ||
//// | ||
//// @Test | ||
//// fun `getPeopleByName should return list of people`() = runBlocking { | ||
//// // Arrange | ||
//// val peopleList = listOf(People(1, "John Doe"), People(2, "John Smith")) | ||
//// Mockito.`when`(peopleDao.getPeopleByName("John")).thenReturn(peopleList) | ||
//// | ||
//// // Act | ||
//// val result = peopleRepository.getPeopleByName("John") | ||
//// | ||
//// // Assert | ||
//// assertEquals(peopleList, result) | ||
//// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/example/rememberme/presentation/details/PersonDetailsEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.example.rememberme.presentation.details | ||
|
||
sealed class PersonDetailsEvent { | ||
data class LoadPerson(val personId: Long) : PersonDetailsEvent() | ||
data object NavigateUp : PersonDetailsEvent() | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/example/rememberme/presentation/details/PersonDetailsUiState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.example.rememberme.presentation.details | ||
|
||
import com.example.rememberme.domain.model.People | ||
|
||
data class PersonDetailsUiState( | ||
val person: People? = null, | ||
val isLoading: Boolean = false, | ||
val error: String? = null | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.