https://kotlinlang.org logo
j

javidev

08/29/2017, 7:22 PM
Hey @edvin, sorry about the delay, I'm on a very different timezone apparently. So I wrote a test to show you what I'm trying to do, it fails on the very last line.
Copy code
data class PojoClass(val name: String)

class PojoViewModel : ItemViewModel<PojoClass>() {
    val name = bind(PojoClass::name)
}

class ItemViewModelTest {

    @Test
    fun testCommit() {
        FxToolkit.registerPrimaryStage()
        val model = PojoViewModel()
        model.item = PojoClass("original")
        Assert.assertTrue(model.item.name == "original")

        model.name.value = "modified"
        Assert.assertFalse(model.item.name == "modified")
        Assert.assertTrue(model.isDirty)

        model.commit()
        Assert.assertTrue(model.item.name == "modified")
    }
}