Ejemplo n.º 1
0
        public void SetCommand_OnButtonWithBindingNoEventName_ParameterShouldUpdate()
        {
            var value = DateTime.Now.Ticks.ToString();

            var vmSource = new TestViewModel
            {
                Model = new TestModel
                {
                    StringProperty = value
                }
            };

            var vmTarget = new TestViewModel();

            var control = new UIButtonEx();

            _binding = new Binding <string, string>(
                vmSource,
                () => vmSource.Model.StringProperty);

            control.SetCommand(
                vmTarget.SetPropertyCommand,
                _binding);

            Assert.IsNull(vmTarget.TargetProperty);
            control.PerformEvent();
            Assert.AreEqual(value, vmTarget.TargetProperty);

            value += "Test";
            vmSource.Model.StringProperty = value;
            control.PerformEvent();
            Assert.AreEqual(value, vmTarget.TargetProperty);
        }
Ejemplo n.º 2
0
        public void SetCommand_WithICommandOnButtonNoValueNoEventName_ClickEventShouldBeUsed()
        {
            var vmTarget = new TestViewModel();
            var control  = new UIButtonEx();

            control.SetCommand(vmTarget.TestCommandImpl);

            var castedCommand = (CommandImpl)vmTarget.TestCommandImpl;

            Assert.IsNull(castedCommand.Parameter);
            control.PerformEvent();
            Assert.AreEqual(TestViewModel.ValueForCommand, castedCommand.Parameter);
        }
Ejemplo n.º 3
0
        public void SetCommand_WithICommandOnButtonNoValue_NoError()
        {
            var vmTarget = new TestViewModel();
            var control  = new UIButtonEx();

            control.SetCommand("TouchUpInside", vmTarget.TestCommandImpl);

            var castedCommand = (CommandImpl)vmTarget.TestCommandImpl;

            Assert.IsNull(castedCommand.Parameter);
            control.PerformEvent();
            Assert.AreEqual(TestViewModel.ValueForCommand, castedCommand.Parameter);
        }
Ejemplo n.º 4
0
        public void SetCommand_OnButtonWithSimpleValueNoEventName_ClickEventShouldBeUsed()
        {
            var value    = DateTime.Now.Ticks.ToString();
            var vmTarget = new TestViewModel();

            var control = new UIButtonEx();

            control.SetCommand(
                vmTarget.SetPropertyCommand,
                value);

            Assert.IsNull(vmTarget.TargetProperty);
            control.PerformEvent();
            Assert.AreEqual(value, vmTarget.TargetProperty);
        }
Ejemplo n.º 5
0
        public void SetCommand_OnButtonNoValue_NoError()
        {
            var value    = DateTime.Now.Ticks.ToString();
            var vmTarget = new TestViewModel();

            vmTarget.Configure(value);

            var control = new UIButtonEx();

            control.SetCommand("TouchUpInside", vmTarget.SetPropertyWithoutValueCommand);

            Assert.IsNull(vmTarget.TargetProperty);
            control.PerformEvent();
            Assert.AreEqual(value, vmTarget.TargetProperty);
        }