public void Disposing_a_TwoWay_Binding_Should_Set_Default_Value_On_Binding_Target_But_Not_On_Source() { var target = new Class3(); // Create a source class which has a Value set to -1 and a Minimum set to -2 var source = new TestTwoWayBindingViewModel() { Value = -1, Minimum = -2 }; // Reset the setter counter source.ResetSetterCalled(); // 1. bind the minimum var disposable_1 = target.Bind(Class3.MinimumProperty, new Binding("Minimum", BindingMode.TwoWay) { Source = source }); // 2. Bind the value var disposable_2 = target.Bind(Class3.ValueProperty, new Binding("Value", BindingMode.TwoWay) { Source = source }); // Dispose the minimum binding disposable_1.Dispose(); // Dispose the value binding disposable_2.Dispose(); // The value setter should be called here as we have disposed minimum fist and the default value of minimum is 0, so this should be changed. Assert.True(source.ValueSetterCalled); // The minimum value should not be changed in the source. Assert.False(source.MinimumSetterCalled); }
public void TwoWay_Binding_Should_Not_Call_Setter_On_Creation_Indexer_With_Value() { var target = new Class1(); var source = new TestTwoWayBindingViewModel() { [0] = 1 }; source.ResetSetterCalled(); target.Bind(Class1.DoubleValueProperty, new Binding("[0]", BindingMode.TwoWay) { Source = source }); Assert.False(source.SetterCalled); }