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 IDEA live template generates a dummy Store factory. The name of the Store is | |
Installation: | |
1. Open IDEA preferences -> Editor -> Live Templates | |
2. Create a new group using the "+" button or select an existing group | |
3. Copy the content of the template below and paste it under the selected group (Ctrl+C/Ctrl+V) | |
Usage: | |
1. Create a new Kotlin file with the name "FooStoreFactory.kt", where "Foo" is the name of the Store | |
2. Type "mvisf" and press Enter |
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
// Deps | |
interface Database | |
interface Network | |
// Child | |
interface ChildRepository | |
class Child(dependencies: Dependencies) { |
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
class UserFragment : Fragment() { | |
private lateinit var userId: String | |
private lateinit var userRepository: UserRepository | |
} | |
interface UserRepository { | |
fun loadUser(id: String): User | |
} |
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
//region UserFragment module | |
class UserFragment(dataSource: UserDataSource) : Fragment() | |
interface UserDataSource { | |
fun getUser(): User | |
} | |
//endregion UserFragment module |
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
@Test | |
fun reloads_images_WHEN_Event_RefreshTriggered() { | |
dataSource.generateImages() | |
startComponent() | |
val newImages = dataSource.generateImages() | |
view.dispatch(Event.RefreshTriggered) | |
assertEquals(newImages, view.model.imageUrls) | |
} |
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
@Test | |
fun loads_and_shows_images_WHEN_created() { | |
val images = dataSource.generateImages() | |
startComponent() | |
assertEquals(images, view.model.imageUrls) | |
} |
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
class KittenComponentTest { | |
private val dataSourceScheduler = TestScheduler() | |
private val dataSource = TestKittenDataSource(dataSourceScheduler) | |
private val view = TestKittenView() | |
private fun startComponent(): KittenComponent = | |
KittenComponent(dataSource).apply { | |
onViewCreated(view) | |
onStart() | |
} |
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
class KittenComponentTest { | |
private val dataSourceScheduler = TestScheduler() | |
private val dataSource = TestKittenDataSource(dataSourceScheduler) | |
private val view = TestKittenView() | |
private fun startComponent(): KittenComponent = | |
KittenComponent(dataSource).apply { | |
onViewCreated(view) | |
onStart() | |
} |
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
class TestKittenView : AbstractMviView<Model, Event>(), KittenView { | |
lateinit var model: Model | |
override fun render(model: Model) { | |
this.model = model | |
} | |
} |
NewerOlder