Skip to content
Snippets Groups Projects
Unverified Commit cafc42d5 authored by Hee Tatt Ooi's avatar Hee Tatt Ooi Committed by GitHub
Browse files

TracingStatusHelper unit test (#114)

* TracingStatusHelper unit test

* removed duplicate
parent 5136f5e9
No related branches found
No related tags found
No related merge requests found
package de.rki.coronawarnapp
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
/**
* 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("de.rki.coronawarnapp", appContext.packageName)
}
}
package de.rki.coronawarnapp
import org.junit.Assert.assertEquals
import org.junit.Test
/**
* 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)
}
}
package de.rki.coronawarnapp.util.formatter
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.MatcherAssert.assertThat
import org.junit.Test
class TracingStatusHelperTest {
@Test
fun testTracingActiveAllOn() {
val result = tracingStatusHelper(tracing = true, bluetooth = true, connection = true)
assertThat(result, `is`((TracingStatusHelper.TRACING_ACTIVE)))
}
@Test
fun testTracingInactiveWhenAllOff() {
val result = tracingStatusHelper(tracing = false, bluetooth = false, connection = false)
assertThat(result, `is`((TracingStatusHelper.TRACING_INACTIVE)))
}
@Test
fun testTracingInactiveWhenTracingOffBluetoothOffConnectionOn() {
val result = tracingStatusHelper(tracing = false, bluetooth = false, connection = true)
assertThat(result, `is`((TracingStatusHelper.TRACING_INACTIVE)))
}
@Test
fun testTracingInactiveWhenTracingOffBluetoothOnConnectionOff() {
val result = tracingStatusHelper(tracing = false, bluetooth = true, connection = false)
assertThat(result, `is`((TracingStatusHelper.TRACING_INACTIVE)))
}
@Test
fun testTracingInactiveWhenTracingOffBluetoothOnConnectionOn() {
val result = tracingStatusHelper(tracing = false, bluetooth = true, connection = true)
assertThat(result, `is`((TracingStatusHelper.TRACING_INACTIVE)))
}
@Test
fun testBluetoothInactiveWhenTracingOnBluetoothOffConnectionOn() {
val result = tracingStatusHelper(tracing = true, bluetooth = false, connection = true)
assertThat(result, `is`((TracingStatusHelper.BLUETOOTH)))
}
@Test
fun testBluetoothInactiveWhenTracingOnBluetoothOffConnectionOff() {
val result = tracingStatusHelper(tracing = true, bluetooth = false, connection = false)
assertThat(result, `is`((TracingStatusHelper.BLUETOOTH)))
}
@Test
fun testConnectionInactiveWhenTracingOnBluetoothOffConnectionOff() {
val result = tracingStatusHelper(tracing = true, bluetooth = true, connection = false)
assertThat(result, `is`((TracingStatusHelper.CONNECTION)))
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment