diff --git a/themes/src/androidTest/java/dev/lucasnlm/antimine/themes/ExampleInstrumentedTest.kt b/themes/src/androidTest/java/dev/lucasnlm/antimine/themes/ExampleInstrumentedTest.kt deleted file mode 100644 index a8c1c7c7..00000000 --- a/themes/src/androidTest/java/dev/lucasnlm/antimine/themes/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package dev.lucasnlm.antimine.themes - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("dev.lucasnlm.antimine.themes.test", appContext.packageName) - } -} diff --git a/themes/src/test/java/dev/lucasnlm/antimine/themes/ExampleUnitTest.kt b/themes/src/test/java/dev/lucasnlm/antimine/themes/ExampleUnitTest.kt deleted file mode 100644 index a21b1d93..00000000 --- a/themes/src/test/java/dev/lucasnlm/antimine/themes/ExampleUnitTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package dev.lucasnlm.antimine.themes - -import org.junit.Test - -import org.junit.Assert.* - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} diff --git a/app/src/test/java/dev/lucasnlm/antimine/theme/ThemeViewModelTest.kt b/themes/src/test/java/dev/lucasnlm/antimine/themes/ThemeViewModelTest.kt similarity index 89% rename from app/src/test/java/dev/lucasnlm/antimine/theme/ThemeViewModelTest.kt rename to themes/src/test/java/dev/lucasnlm/antimine/themes/ThemeViewModelTest.kt index ef02eb3d..961f8685 100644 --- a/app/src/test/java/dev/lucasnlm/antimine/theme/ThemeViewModelTest.kt +++ b/themes/src/test/java/dev/lucasnlm/antimine/themes/ThemeViewModelTest.kt @@ -1,24 +1,42 @@ -package dev.lucasnlm.antimine.theme +package dev.lucasnlm.antimine.themes -import dev.lucasnlm.antimine.IntentViewModelTest -import dev.lucasnlm.antimine.common.R import dev.lucasnlm.external.IAnalyticsManager import dev.lucasnlm.antimine.preferences.IPreferencesRepository +import dev.lucasnlm.antimine.themes.viewmodel.ThemeEvent +import dev.lucasnlm.antimine.themes.viewmodel.ThemeState +import dev.lucasnlm.antimine.themes.viewmodel.ThemeViewModel import dev.lucasnlm.antimine.ui.model.AppTheme import dev.lucasnlm.antimine.ui.model.AreaPalette import dev.lucasnlm.antimine.ui.model.Assets import dev.lucasnlm.antimine.ui.repository.IThemeRepository -import dev.lucasnlm.antimine.theme.viewmodel.ThemeEvent -import dev.lucasnlm.antimine.theme.viewmodel.ThemeState -import dev.lucasnlm.antimine.theme.viewmodel.ThemeViewModel import dev.lucasnlm.external.IBillingManager import io.mockk.every import io.mockk.mockk import io.mockk.verify +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.TestCoroutineDispatcher +import kotlinx.coroutines.test.resetMain +import kotlinx.coroutines.test.setMain +import org.junit.After import org.junit.Assert.assertEquals +import org.junit.Before import org.junit.Test -class ThemeViewModelTest : IntentViewModelTest() { +@ExperimentalCoroutinesApi +class ThemeViewModelTest { + private val dispatcher = TestCoroutineDispatcher() + + @Before + fun setup() { + Dispatchers.setMain(dispatcher) + } + + @After + fun tearDown() { + Dispatchers.resetMain() + } + private val lightTheme = AppTheme( id = 1L, theme = R.style.CustomLightTheme,