parent
6059a62b94
commit
3f8488b935
1 changed files with 22 additions and 0 deletions
|
@ -8,15 +8,37 @@ import info.nightscout.shared.utils.T
|
||||||
import info.nightscout.sharedtests.TestBase
|
import info.nightscout.sharedtests.TestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.junit.jupiter.api.BeforeAll
|
||||||
|
import org.junit.jupiter.api.AfterAll
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
import java.util.SimpleTimeZone
|
||||||
|
import java.util.TimeZone
|
||||||
|
|
||||||
class DateUtilTest : TestBase() {
|
class DateUtilTest : TestBase() {
|
||||||
|
|
||||||
@Mock lateinit var context: Context
|
@Mock lateinit var context: Context
|
||||||
@Mock lateinit var rh: ResourceHelper
|
@Mock lateinit var rh: ResourceHelper
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
private lateinit var savedTimeZone: TimeZone
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
@JvmStatic
|
||||||
|
fun setDefaultTimezoneUtc() {
|
||||||
|
savedTimeZone = TimeZone.getDefault()
|
||||||
|
TimeZone.setDefault(SimpleTimeZone(0, "UTC"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterAll
|
||||||
|
@JvmStatic
|
||||||
|
fun restoreDefaultTimezone() {
|
||||||
|
TimeZone.setDefault(savedTimeZone)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun fromISODateStringTest() {
|
fun fromISODateStringTest() {
|
||||||
Assertions.assertEquals(1511124634417L, DateUtil(context).fromISODateString("2017-11-19T22:50:34.417+0200"))
|
Assertions.assertEquals(1511124634417L, DateUtil(context).fromISODateString("2017-11-19T22:50:34.417+0200"))
|
||||||
|
|
Loading…
Reference in a new issue