use of javafx.beans.value.WritableIntegerValue in project dolphin-platform by canoo.
the class FXBinderTest method testJavaFXIntegerUnidirectional.
@Test
public void testJavaFXIntegerUnidirectional() {
Property<Integer> integerDolphinProperty = new MockedProperty<>();
Property<Number> numberDolphinProperty = new MockedProperty<>();
IntegerProperty integerJavaFXProperty = new SimpleIntegerProperty();
WritableIntegerValue writableIntegerValue = new SimpleIntegerProperty();
integerDolphinProperty.set(47);
assertNotEquals(integerJavaFXProperty.doubleValue(), 47);
Binding binding = FXBinder.bind(integerJavaFXProperty).to(integerDolphinProperty);
assertEquals(integerJavaFXProperty.get(), 47);
integerDolphinProperty.set(100);
assertEquals(integerJavaFXProperty.get(), 100);
integerDolphinProperty.set(null);
assertEquals(integerJavaFXProperty.get(), 0);
binding.unbind();
integerDolphinProperty.set(100);
assertEquals(integerJavaFXProperty.get(), 0);
numberDolphinProperty.set(12);
binding = FXBinder.bind(integerJavaFXProperty).to(numberDolphinProperty);
assertEquals(integerJavaFXProperty.get(), 12);
numberDolphinProperty.set(null);
assertEquals(integerJavaFXProperty.get(), 0);
binding.unbind();
numberDolphinProperty.set(100);
assertEquals(integerJavaFXProperty.get(), 0);
integerDolphinProperty.set(47);
binding = FXBinder.bind(writableIntegerValue).to(integerDolphinProperty);
assertEquals(writableIntegerValue.get(), 47);
integerDolphinProperty.set(100);
assertEquals(writableIntegerValue.get(), 100);
integerDolphinProperty.set(null);
assertEquals(writableIntegerValue.get(), 0);
binding.unbind();
integerDolphinProperty.set(100);
assertEquals(writableIntegerValue.get(), 0);
}
Aggregations