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);
        }
Example #2
0
        public void GetBaseValue_Style_Ignores_LocalValue_Animated_Value()
        {
            var target = new Class3();

            target.Bind(Class1.FooProperty, new BehaviorSubject <string>("animated"), BindingPriority.Animation);
            target.SetValue(Class1.FooProperty, "local");
            Assert.False(target.GetBaseValue(Class1.FooProperty, BindingPriority.Style).HasValue);
        }
Example #3
0
        public void GetBaseValue_Style_Returns_Style_Value()
        {
            var target = new Class3();

            target.SetValue(Class1.FooProperty, "local");
            target.SetValue(Class1.FooProperty, "style", BindingPriority.Style);
            target.Bind(Class1.FooProperty, new BehaviorSubject <string>("animated"), BindingPriority.Animation);
            Assert.Equal("style", target.GetBaseValue(Class1.FooProperty, BindingPriority.Style));
        }