<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.yobidashi.media.image.preview

import android.graphics.ColorFilter
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.InjectMockKs
import io.mockk.impl.annotations.MockK
import io.mockk.unmockkAll
import io.mockk.verify
import org.junit.After
import org.junit.Before
import org.junit.Test

class ColorFilterUseCaseTest {

    @InjectMockKs
    private lateinit var colorFilterUseCase: ColorFilterUseCase

    @MockK
    private lateinit var viewModel: ImagePreviewFragmentViewModel

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

        every { viewModel.newColorFilter(any<ColorFilter>()) }.answers { Unit }
        every { viewModel.newColorFilter(any<ImageColorFilter>()) }.answers { Unit }
    }

    @After
    fun tearDown() {
        unmockkAll()
    }

    @Test
    fun testApplyAlpha() {
        colorFilterUseCase.applyAlpha(0.5f)

        verify(exactly = 1) { viewModel.newColorFilter(any<ColorFilter>()) }
        verify(exactly = 0) { viewModel.newColorFilter(any<ImageColorFilter>()) }
    }

    @Test
    fun applyContrast() {
        colorFilterUseCase.applyContrast(0.5f)

        verify(exactly = 1) { viewModel.newColorFilter(any<ColorFilter>()) }
        verify(exactly = 0) { viewModel.newColorFilter(any<ImageColorFilter>()) }<commit_msg>refactor #506 Rename test function.<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.yobidashi.media.image.preview

import android.graphics.ColorFilter
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.InjectMockKs
import io.mockk.impl.annotations.MockK
import io.mockk.unmockkAll
import io.mockk.verify
import org.junit.After
import org.junit.Before
import org.junit.Test

class ColorFilterUseCaseTest {

    @InjectMockKs
    private lateinit var colorFilterUseCase: ColorFilterUseCase

    @MockK
    private lateinit var viewModel: ImagePreviewFragmentViewModel

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

        every { viewModel.newColorFilter(any<ColorFilter>()) }.answers { Unit }
        every { viewModel.newColorFilter(any<ImageColorFilter>()) }.answers { Unit }
    }

    @After
    fun tearDown() {
        unmockkAll()
    }

    @Test
    fun testApplyAlpha() {
        colorFilterUseCase.applyAlpha(0.5f)

        verify(exactly = 1) { viewModel.newColorFilter(any<ColorFilter>()) }
        verify(exactly = 0) { viewModel.newColorFilter(any<ImageColorFilter>()) }
    }

    @Test
    fun testApplyContrast() {
        colorFilterUseCase.applyContrast(0.5f)

        verify(exactly = 1) { viewModel.newColorFilter(any<ColorFilter>()) }
        verify(exactly = 0) { viewModel.newColorFilter(any<ImageColorFilter>()) }
{'fraction_non_alphanumeric': 0.09946396664681358, 'fraction_numerical': 0.01042287075640262, 'mean_word_length': 3.6782729805013927, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '1223570', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1010, 'n_words': 224}