<commit_before>/*
 * Copyright (c) 2021 toastkidjp.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompany this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html.
 */

package jp.toastkid.lib.color

import android.content.res.Configuration
import android.graphics.Color
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.InjectMockKs
import io.mockk.impl.annotations.MockK
import io.mockk.mockkConstructor
import io.mockk.unmockkAll
import io.mockk.verify
import jp.toastkid.lib.night.DisplayMode
import jp.toastkid.lib.preference.PreferenceApplier
import org.junit.After
import org.junit.Before
import org.junit.Test

class IconColorFinderTest {

    @InjectMockKs
    private lateinit var iconColorFinder: IconColorFinder

    @MockK
    private lateinit var configuration: Configuration

    @MockK
    private lateinit var preferenceApplier: PreferenceApplier

    @Before
    fun setUp() {
        MockKAnnotations.init(this)

        mockkConstructor(DisplayMode::class)
        every { preferenceApplier.fontColor }.returns(Color.BLACK)
        every { preferenceApplier.color }.returns(Color.WHITE)
    }

    @After
    fun tearDown() {
        unmockkAll()
    }

    @Test
    fun test() {
        every { anyConstructed<DisplayMode>().isNightMode() }.returns(true)

        iconColorFinder.invoke()

        verify (exactly = 1) { anyConstructed<DisplayMode>().isNightMode() }
        verify (exactly = 1) { preferenceApplier.fontColor }
        verify (exactly = 0) { preferenceApplier.color }
    }

    @Test
    fun testFalseCase() {
        every { anyConstructed<DisplayMode>().isNightMode() }.returns(false)

        iconColorFinder.invoke()

        verify (exactly = 1) { anyConstructed<DisplayMode>().isNightMode() }
        verify (exactly = 0) { preferenceApplier.fontColor }
        verify (exactly = 1) { preferenceApplier.color }
    }

}<commit_msg>refactor #523 Rename test case.<commit_after>/*
 * Copyright (c) 2021 toastkidjp.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompany this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html.
 */

package jp.toastkid.lib.color

import android.content.res.Configuration
import android.graphics.Color
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.InjectMockKs
import io.mockk.impl.annotations.MockK
import io.mockk.mockkConstructor
import io.mockk.unmockkAll
import io.mockk.verify
import jp.toastkid.lib.night.DisplayMode
import jp.toastkid.lib.preference.PreferenceApplier
import org.junit.After
import org.junit.Before
import org.junit.Test

class IconColorFinderTest {

    @InjectMockKs
    private lateinit var iconColorFinder: IconColorFinder

    @MockK
    private lateinit var configuration: Configuration

    @MockK
    private lateinit var preferenceApplier: PreferenceApplier

    @Before
    fun setUp() {
        MockKAnnotations.init(this)

        mockkConstructor(DisplayMode::class)
        every { preferenceApplier.fontColor }.returns(Color.BLACK)
        every { preferenceApplier.color }.returns(Color.WHITE)
    }

    @After
    fun tearDown() {
        unmockkAll()
    }

    @Test
    fun testDarkCase() {
        every { anyConstructed<DisplayMode>().isNightMode() }.returns(true)

        iconColorFinder.invoke()

        verify (exactly = 1) { anyConstructed<DisplayMode>().isNightMode() }
        verify (exactly = 1) { preferenceApplier.fontColor }
        verify (exactly = 0) { preferenceApplier.color }
    }

    @Test
    fun testNormalCase() {
        every { anyConstructed<DisplayMode>().isNightMode() }.returns(false)

        iconColorFinder.invoke()

        verify (exactly = 1) { anyConstructed<DisplayMode>().isNightMode() }
        verify (exactly = 0) { preferenceApplier.fontColor }
        verify (exactly = 1) { preferenceApplier.color }
    }

}
{'fraction_non_alphanumeric': 0.09498680738786279, 'fraction_numerical': 0.0074358359318781484, 'mean_word_length': 3.4456289978678036, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5450441', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1224, 'n_words': 286}