Slide 116
Slide 116 text
class MoshiTestKrate(context: Context) : SimpleKrate(context) {
var simpleValue: TestModel? by moshiPref("simpleValue")
var listOfValues: List? by moshiPref("listOfValues")
}
@Test
fun testListOfValues() {
val list = listOf(
TestModel(x = 42, y = 3.141592, z = "shibboleth"),
TestModel(x = 13, y = 6.283185, z = "signal"),
)
krate.listOfValues = list
assertEquals(list, krate.listOfValues)
}
data class TestModel(val x: Int, val y: Double, val z: String)
val krate = MoshiTestKrate(targetContext)
Moshi delegate tests
java.lang.AssertionError:
Expected :[
TestModel(x=42, y=3.141592, z=shibboleth),
TestModel(x=13, y=6.283185, z=signal)
]
Actual :[
{x=42.0, y=3.141592, z=shibboleth},
{x=13.0, y=6.283185, z=signal}
]