Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bidetofevil committed Oct 23, 2023
1 parent c91ab5e commit 16a61f8
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.embrace.android.embracesdk.internal

import io.embrace.android.embracesdk.fakes.FakeClock
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test

internal class SdkApiImplTest {

private lateinit var fakeClock: FakeClock
private lateinit var sdkApi: SdkApiImpl

@Before
fun setup() {
fakeClock = FakeClock(currentTime = beforeObjectInitTime)
sdkApi = SdkApiImpl(fakeClock)
}

@Test
fun `check usage of SDK time`() {
assertEquals(beforeObjectInitTime, sdkApi.getSdkCurrentTime())
assertTrue(sdkApi.getSdkCurrentTime() < System.currentTimeMillis())
fakeClock.tick(10L)
assertEquals(fakeClock.now(), sdkApi.getSdkCurrentTime())
}

@Test
fun `check default implementation`() {
assertTrue(beforeObjectInitTime < default.getSdkCurrentTime())
assertTrue(default.getSdkCurrentTime() <= System.currentTimeMillis())
}

companion object {
val beforeObjectInitTime = System.currentTimeMillis() - 1
}
}

0 comments on commit 16a61f8

Please sign in to comment.