chore: core 多模块骨架

This commit is contained in:
AndyChen1024
2026-09-03 19:03:35 +08:00
parent 41a8a7a5f3
commit 3a5f1ed679
21 changed files with 222 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
package com.mingyuan.android_client.core.domain
/**
* Base contract for a single-action use case.
*
* Keeping use cases as plain interfaces with a `suspend operator invoke` keeps domain logic
* framework-agnostic and trivially testable on the JVM (see [com.mingyuan.android_client.core.domain.UseCaseTest]).
*/
interface UseCase<in Input, out Output> {
suspend operator fun invoke(input: Input): Output
}

View File

@@ -0,0 +1,17 @@
package com.mingyuan.android_client.core.domain
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runTest
import org.junit.Test
class UseCaseTest {
@Test
fun `invoke delegates to the implementation`() = runTest {
val double = object : UseCase<Int, Int> {
override suspend fun invoke(input: Int): Int = input * 2
}
assertThat(double(21)).isEqualTo(42)
}
}