Ejemplo n.º 1
0
        public void GetBaseValue_LocalValue_Ignores_Default_Value()
        {
            var target = new Class3();

            target.SetValue(Class1.FooProperty, "animated", BindingPriority.Animation);
            Assert.False(target.GetBaseValue(Class1.FooProperty, BindingPriority.LocalValue).HasValue);
        }
        public void Validation_Can_Be_Overridden_With_Null()
        {
            var target = new Class3();

            target.SetValue(Class1.QuxProperty, 50);
            Assert.Equal(50, target.GetValue(Class1.QuxProperty));
        }
        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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public void GetBaseValue_LocalValue_Returns_Style_Value()
        {
            var target = new Class3();

            target.SetValue(Class1.FooProperty, "style", BindingPriority.Style);
            target.SetValue(Class1.FooProperty, "animated", BindingPriority.Animation);
            Assert.Equal("style", target.GetBaseValue(Class1.FooProperty, BindingPriority.LocalValue).Value);
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
0
        public void GetValue_Doesnt_Throw_Exception_For_Unregistered_Property()
        {
            var target = new Class3();

            Assert.Equal("foodefault", target.GetValue(Class1.FooProperty));
        }
        public void GetValue_Throws_Exception_For_Unregistered_Property()
        {
            var target = new Class3();

            Assert.Throws <ArgumentException>(() => target.GetValue(Class1.FooProperty));
        }