Move ThemeViewModel test

This commit is contained in:
Lucas Lima 2020-12-31 18:13:30 -03:00 committed by Lucas Nunes
parent 7f33e36cc4
commit 504a160ddf
3 changed files with 25 additions and 48 deletions

View file

@ -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)
}
}

View file

@ -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)
}
}

View file

@ -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.external.IAnalyticsManager
import dev.lucasnlm.antimine.preferences.IPreferencesRepository 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.AppTheme
import dev.lucasnlm.antimine.ui.model.AreaPalette import dev.lucasnlm.antimine.ui.model.AreaPalette
import dev.lucasnlm.antimine.ui.model.Assets import dev.lucasnlm.antimine.ui.model.Assets
import dev.lucasnlm.antimine.ui.repository.IThemeRepository 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 dev.lucasnlm.external.IBillingManager
import io.mockk.every import io.mockk.every
import io.mockk.mockk import io.mockk.mockk
import io.mockk.verify 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.Assert.assertEquals
import org.junit.Before
import org.junit.Test 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( private val lightTheme = AppTheme(
id = 1L, id = 1L,
theme = R.style.CustomLightTheme, theme = R.style.CustomLightTheme,