Exemplo n.º 1
0
        public void Binding_TwoWayFromViewModelToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
        {
            var vm = new TestViewModel
            {
                Model = new TestModel()
            };

            var control1 = new UISwitchEx();

            _binding = new Binding <string, bool>(
                vm,
                () => vm.Model.StringProperty,
                control1,
                () => control1.On,
                BindingMode.TwoWay)
                       .UpdateTargetTrigger();

            Assert.AreEqual(null, vm.Model.StringProperty);
            Assert.IsFalse(control1.On);
            vm.Model.StringProperty = "True";
            Assert.AreEqual("True", vm.Model.StringProperty);
            Assert.IsTrue(control1.On);

            control1.On = false;
            Assert.IsFalse(control1.On);
            Assert.AreEqual("False", vm.Model.StringProperty);
        }
Exemplo n.º 2
0
        public void Binding_TwoWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
        {
            var vm = new TestViewModel
            {
                Model = new TestModel()
            };

            var control1 = new UISwitchEx();

            _binding = new Binding <bool, string>(
                control1,
                () => control1.On,
                vm,
                () => vm.Model.StringProperty,
                BindingMode.TwoWay)
                       .UpdateSourceTrigger();

            Assert.AreEqual("False", vm.Model.StringProperty);
            Assert.IsFalse(control1.On);
            control1.On = true;
            Assert.AreEqual("True", vm.Model.StringProperty);
            Assert.IsTrue(control1.On);

            var value = "False";

            vm.Model.StringProperty = value;
            Assert.AreEqual(value, vm.Model.StringProperty);
            Assert.IsFalse(control1.On);
        }
Exemplo n.º 3
0
        public void Binding_TwoWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
        {
            var control1 = new UITextViewEx();
            var control2 = new UISwitchEx();

            _binding = new Binding <string, bool>(
                control1,
                () => control1.Text,
                control2,
                () => control2.On,
                BindingMode.TwoWay)
                       .UpdateSourceTrigger()
                       .UpdateTargetTrigger();

            Assert.AreEqual(string.Empty, control1.Text);
            Assert.IsFalse(control2.On);
            var value = "True";

            control1.Text = value;
            Assert.AreEqual(value, control1.Text);
            Assert.IsTrue(control2.On);

            control2.On = false;
            Assert.IsFalse(control2.On);
            Assert.AreEqual("False", control1.Text);
        }
Exemplo n.º 4
0
        public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
        {
            var control1 = new UITextViewEx();
            var control2 = new UISwitchEx();

            _binding = new Binding <bool, string>(
                control2,
                () => control2.On,
                control1,
                () => control1.Text,
                BindingMode.TwoWay)
                       .ObserveSourceEvent(UpdateTriggerMode.PropertyChanged)
                       .ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);

            Assert.AreEqual("False", control1.Text);
            Assert.IsFalse(control2.On);
            control2.On = true;
            Assert.AreEqual("True", control1.Text);
            Assert.IsTrue(control2.On);

            var value = "False";

            control1.Text = value;
            Assert.AreEqual(value, control1.Text);
            Assert.IsFalse(control2.On);
        }
        public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
        {
            var control1 = new UITextViewEx();
            var control2 = new UISwitchEx();

            _binding = new Binding <bool, string>(
                control2,
                () => control2.On,
                control1,
                () => control1.Text);

            Assert.AreEqual("False", control1.Text);
            Assert.IsFalse(control2.On);
            control2.On = true;
            Assert.AreEqual("True", control1.Text);
            Assert.IsTrue(control2.On);
        }
        public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
        {
            var control1 = new UISwitchEx();
            var control2 = new UISwitchEx();

            _binding = new Binding <bool, bool>(
                control1,
                () => control1.On,
                control2,
                () => control2.On);

            Assert.IsFalse(control1.On);
            Assert.IsFalse(control2.On);
            control1.On = true;
            Assert.IsTrue(control1.On);
            Assert.IsTrue(control2.On);
        }
Exemplo n.º 7
0
        public void Binding_OneWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
        {
            var control1 = new UITextViewEx();
            var control2 = new UISwitchEx();

            _binding = new Binding <string, bool>(
                control1,
                () => control1.Text,
                control2,
                () => control2.On)
                       .ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);

            Assert.AreEqual(string.Empty, control1.Text);
            Assert.IsFalse(control2.On);
            var value = "True";

            control1.Text = value;
            Assert.AreEqual(value, control1.Text);
            Assert.IsTrue(control2.On);
        }
Exemplo n.º 8
0
        public void Binding_OneWayFromViewModelToCheckBox_BindingGetsUpdated()
        {
            var vm = new TestViewModel
            {
                Model = new TestModel()
            };

            var control1 = new UISwitchEx();

            _binding = new Binding <string, bool>(
                vm,
                () => vm.Model.StringProperty,
                control1,
                () => control1.On);

            Assert.AreEqual(null, vm.Model.StringProperty);
            Assert.IsFalse(control1.On);
            vm.Model.StringProperty = "True";
            Assert.AreEqual("True", vm.Model.StringProperty);
            Assert.IsTrue(control1.On);
        }
        public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
        {
            var vm = new TestViewModel
            {
                Model = new TestModel()
            };

            var control1 = new UISwitchEx();

            _binding = new Binding <bool, string>(
                control1,
                () => control1.On,
                vm,
                () => vm.Model.MyProperty);

            Assert.AreEqual("False", vm.Model.MyProperty);
            Assert.IsFalse(control1.On);
            control1.On = true;
            Assert.AreEqual("True", vm.Model.MyProperty);
            Assert.IsTrue(control1.On);
        }
Exemplo n.º 10
0
        public void Binding_TwoWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
        {
            var control1 = new UISwitchEx();
            var control2 = new UISwitchEx();

            _binding = new Binding <bool, bool>(
                control1,
                () => control1.On,
                control2,
                () => control2.On,
                BindingMode.TwoWay)
                       .UpdateSourceTrigger()
                       .UpdateTargetTrigger();

            Assert.IsFalse(control1.On);
            Assert.IsFalse(control2.On);
            control1.On = true;
            Assert.IsTrue(control1.On);
            Assert.IsTrue(control2.On);

            control2.On = false;
            Assert.IsFalse(control2.On);
            Assert.IsFalse(control1.On);
        }