mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
defined the key variable
This commit is contained in:
parent
6e929e3786
commit
860854a940
1 changed files with 11 additions and 7 deletions
|
|
@ -48,29 +48,33 @@ class JsonKvStoreTest {
|
|||
|
||||
@Test
|
||||
fun getJson() {
|
||||
whenever(prefs.getString("key", null)).thenReturn(expected)
|
||||
val key = "key" // Define the key variable
|
||||
|
||||
val result = store.getJson("key", Person::class.java)
|
||||
whenever(prefs.getString(key, null)).thenReturn(expected)
|
||||
|
||||
val result = store.getJson(key, Person::class.java)
|
||||
|
||||
Assert.assertEquals(testData, result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getJsonInTheFuture() {
|
||||
whenever(prefs.getString("key", null)).thenReturn(expected)
|
||||
val key = "key" // Define the key variable
|
||||
whenever(prefs.getString(key, null)).thenReturn(expected)
|
||||
|
||||
val resultOne: Person? = store.getJson("key")
|
||||
val resultOne: Person? = store.getJson(key)
|
||||
Assert.assertEquals(testData, resultOne)
|
||||
|
||||
val resultTwo = store.getJson<Person?>("key")
|
||||
val resultTwo = store.getJson<Person?>(key)
|
||||
Assert.assertEquals(testData, resultTwo)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getJsonHandlesMalformedJson() {
|
||||
whenever(prefs.getString("key", null)).thenReturn("junk")
|
||||
val key = "key" // Define the key variable
|
||||
whenever(prefs.getString(key, null)).thenReturn("junk")
|
||||
|
||||
val result = store.getJson("key", Person::class.java)
|
||||
val result = store.getJson(key, Person::class.java)
|
||||
|
||||
Assert.assertNull(result)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue