@Test public void whenTrueRemovesFromInitialSet() { final BooleanProperty b = booleanProperty("b", false); final ArrayList<String> list = new ArrayList<String>(); list.add("foo"); binder.when(b).is(true).add("foo").to(list); assertThat(list, not(hasItem("foo"))); }
@Test public void whenValueAddToListDoesNotInitializeProperty() { final EnumProperty<Color> color = enumProperty("color"); final ArrayList<String> list = new ArrayList<String>(); // foo isn't in the list, so we leave color alone binder.when(color).is(Color.BLUE).add("foo").to(list); assertThat(color.get(), is(nullValue())); assertThat(color.isTouched(), is(false)); }
@Test public void whenTrueAddDoesInitialSet() { final BooleanProperty b = booleanProperty("b", true); final ArrayList<String> list = new ArrayList<String>(); binder.when(b).is(true).add("foo").to(list); assertThat(list, contains("foo")); }
@Test public void whenValueAddToListInitializesProperty() { final EnumProperty<Color> color = enumProperty("color"); // null so we'll do the initial set final ArrayList<String> list = new ArrayList<String>(); list.add("foo"); binder.when(color).is(Color.BLUE).add("foo").to(list); assertThat(color.get(), is(Color.BLUE)); assertThat(color.isTouched(), is(false)); assertThat(list, contains("foo")); }
@Test public void whenValueAddToListPropertyInitializesProperty() { final EnumProperty<Color> color = enumProperty("color"); final ListProperty<String> list = listProperty("list"); list.add("foo"); binder.when(color).is(Color.BLUE).add("foo").to(list); assertThat(color.get(), is(Color.BLUE)); assertThat(color.isTouched(), is(false)); }