Last active
August 10, 2018 03:58
-
-
Save oakkub/b27110c839dd30cef10cf7c7aeb2fd1f to your computer and use it in GitHub Desktop.
Set value to private field, in case we want to inject the mock repository or something.
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
fun FooViewModel.setMockRepository(mockRepository: FooRepository) { | |
val repository = FooViewModel::class.java.getDeclaredField("fooRepository") | |
repository.isAccessible = true | |
repository.set(this, mockRepository) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment