<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.libs.network

import android.content.Context
import android.net.ConnectivityManager
import android.net.Network
import android.net.NetworkCapabilities
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.unmockkAll
import org.junit.After
import org.junit.Assert.assertFalse
import org.junit.Before
import org.junit.Test

/**
 * @author toastkidjp
 */
class NetworkCheckerTest {

    @MockK
    private lateinit var context: Context

    @MockK
    private lateinit var connectivityManager: ConnectivityManager

    @MockK
    private lateinit var network: Network

    @MockK
    private lateinit var networkCapabilities: NetworkCapabilities

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

        every { context.getSystemService(any()) }.returns(connectivityManager)
        every { connectivityManager.activeNetwork }.returns(network)
        every { connectivityManager.getNetworkCapabilities(any()) }.returns(networkCapabilities)
        every { networkCapabilities.hasTransport(any()) }.returns(true)
    }

    @After
    fun tearDown() {
        unmockkAll()
    }

    @Test
    fun testIsNotAvailable() {
        assertFalse(NetworkChecker.isNotAvailable(context))
    }

}<commit_msg>refactor #704 Add 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.yobidashi.libs.network

import android.content.Context
import android.net.ConnectivityManager
import android.net.Network
import android.net.NetworkCapabilities
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.unmockkAll
import org.junit.After
import org.junit.Assert.assertFalse
import org.junit.Before
import org.junit.Test

/**
 * @author toastkidjp
 */
class NetworkCheckerTest {

    @MockK
    private lateinit var context: Context

    @MockK
    private lateinit var connectivityManager: ConnectivityManager

    @MockK
    private lateinit var network: Network

    @MockK
    private lateinit var networkCapabilities: NetworkCapabilities

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

        every { context.getSystemService(any()) }.returns(connectivityManager)
        every { connectivityManager.activeNetwork }.returns(network)
        every { connectivityManager.getNetworkCapabilities(any()) }.returns(networkCapabilities)
        every { networkCapabilities.hasTransport(any()) }.returns(true)
    }

    @After
    fun tearDown() {
        unmockkAll()
    }

    @Test
    fun testIsNotAvailable() {
        assertFalse(NetworkChecker.isNotAvailable(context))
    }

    @Test
    fun test() {
        assertFalse(NetworkChecker.isUnavailableWiFi(context))
    }

}
{'fraction_non_alphanumeric': 0.0850178359096314, 'fraction_numerical': 0.005648038049940547, 'mean_word_length': 3.73943661971831, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7251860', 'n_tokens_mistral': 980, 'n_tokens_neox': 932, 'n_words': 240}