添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
class Repository {
  fun getAll(): List<String> {
    // retrieve or create list of strings somehow
// return only entries containing letter "g"
class UseCase(private val repository: Repository) {
  fun execute(): List<String> {
    return repository.getAll().filter { it.contains("g") }

And following test method:

class UseCaseTest {
  @Test
  fun `it should return elements containing letter g`() {
    val mockRepository: Repository = mock {
      on { getAll() } doReturn listOf("kotlin", "testing", "blog")
    val useCase = UseCase(
      repository = mockRepository
    val result = useCase.execute()
    result.size shouldBe 2
				Best practices for Android Architecture in 2024 Android Pro | Architect Masterclass Series			
			

Enroll to 3rd cohort of The Android Architect androidpro.io/architect

Read More »