Use koin in testing module

pull/2064/head
lihenggui 1 year ago
parent 6bd3f6d2fa
commit 78915028d3

@ -15,7 +15,7 @@
*/
plugins {
alias(libs.plugins.nowinandroid.kmp.library)
alias(libs.plugins.nowinandroid.kotlin.inject)
alias(libs.plugins.nowinandroid.di.koin)
}
android {

@ -19,12 +19,9 @@ package com.google.samples.apps.nowinandroid.core.testing.di
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestDispatcher
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import me.tatarka.inject.annotations.Component
import me.tatarka.inject.annotations.Provides
import org.koin.dsl.module
@Component
internal abstract class TestDispatcherModule {
@OptIn(ExperimentalCoroutinesApi::class)
@Provides
fun providesTestDispatcher(): TestDispatcher = UnconfinedTestDispatcher()
@OptIn(ExperimentalCoroutinesApi::class)
val testDispatcherModule = module {
single { UnconfinedTestDispatcher() }
}

@ -1,28 +0,0 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.samples.apps.nowinandroid.core.testing.di
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.test.TestDispatcher
import me.tatarka.inject.annotations.Component
import me.tatarka.inject.annotations.Provides
@Component
internal abstract class TestDispatchersModule {
@Provides
fun providesDispatcher(testDispatcher: TestDispatcher): CoroutineDispatcher = testDispatcher
}
Loading…
Cancel
Save