コード例 #1
3
ファイル: SetCommandTest.cs プロジェクト: dsfranzi/MVVMLight
        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);
        }
コード例 #2
0
ファイル: SetCommandTest.cs プロジェクト: dsfranzi/MVVMLight
        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);
        }
コード例 #3
0
ファイル: SetCommandTest.cs プロジェクト: dsfranzi/MVVMLight
        public void SetCommand_OnButtonWithSimpleValue_NoError()
        {
            var value = DateTime.Now.Ticks.ToString();
            var vmTarget = new TestViewModel();

            var control = new UIButtonEx();

            control.SetCommand(
                "TouchUpInside",
                vmTarget.SetPropertyCommand,
                value);

            Assert.IsNull(vmTarget.TargetProperty);
            control.PerformEvent();
            Assert.AreEqual(value, vmTarget.TargetProperty);
        }
コード例 #4
0
ファイル: SetCommandTest.cs プロジェクト: dsfranzi/MVVMLight
        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);
        }
コード例 #5
0
ファイル: SetCommandTest.cs プロジェクト: dsfranzi/MVVMLight
        public void SetCommand_OnButtonWithBindingNoEventName_ParameterShouldUpdate()
        {
            var value = DateTime.Now.Ticks.ToString();

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

            var vmTarget = new TestViewModel();

            var control = new UIButtonEx();

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

            control.SetCommand(
                vmTarget.SetPropertyCommand,
                _binding);

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

            value += "Test";
            vmSource.Model.MyProperty = value;
            control.PerformEvent();
            Assert.AreEqual(value, vmTarget.TargetProperty);
        }