This file contains hidden or 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
fun assertThat(someViewModel: SomeViewModel): ViewModelStateVerifier { // inspired by Hamcrest | |
return ViewModelStateVerifier(someViewModel) | |
} | |
class ViewModelStateVerifier(private val someViewModel: SomeViewModel) { | |
fun loaderIsShown(): ViewModelStateVerifier { | |
assertTrue(someViewModel.getLoaderState().value) | |
return this | |
} |
This file contains hidden or 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
class SomeViewModelTest { | |
private lateinit var someViewModel: SomeViewModel | |
private val someInteractor: SomeInteractor = mockk(relaxed = true) | |
private val dataToLoad: String = "Data to load" | |
@Before | |
fun setUp() { | |
clearAllMocks() | |
} |
This file contains hidden or 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
sealed class ContentState { | |
object Hidden : ContentState() | |
data class Shown(val data: String) : ContentState() | |
} | |
class SomeViewModel( | |
private val someInteractor: SomeInteractor, | |
private val dispatchersProvider: DispatchersProvider | |
) : ViewModel() { |
This file contains hidden or 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
sealed class Icon { | |
data class Resources(val name: String) | |
data class Url(val url: String) | |
} |
This file contains hidden or 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
data class IconResponse( | |
@SerializedName("type") | |
val type: IconTypeEnum, | |
@SerializedName("name") | |
val name: String?, | |
@SerializedName("url") | |
val url: String? | |
) |
This file contains hidden or 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
// Icon from android resource | |
{ | |
"icon": { | |
type: "resources" | |
"name": "resources_name" | |
} | |
} | |
// Icon from url | |
{ |
This file contains hidden or 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
data class YourUiModel( | |
val title: String, | |
val description: String, | |
val visibility: Int // View.GONE, etc | |
) | |
class YourViewHolder( | |
view: View | |
): RecyclerView.ViewHolder(view) { | |
//... |
This file contains hidden or 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
data class YourModelResponse( | |
@SerializedName("field1") | |
val field1: String, | |
@SerializedName("field2") | |
val field2: String | |
) |
This file contains hidden or 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
data class YourDomainDto( | |
val field1: String, | |
val field2: String | |
) |