示例#1
0
        public void ViewModelBase_GetCommandD_Test8()
        {
            var vm             = new MockViewModel();
            var commandInvoked = false;

            var cmd1 = vm.InvokeGetCommandD <int>("Test", x => commandInvoked = true, x => false);
            var cmd2 = vm.InvokeGetCommandD <int>("Test", x => commandInvoked = true, x => false);
            var cmd3 = vm.Test;

            Assert.AreSame(cmd1, cmd2);
            Assert.AreSame(cmd1, cmd3);
            Assert.IsFalse(commandInvoked);
        }
示例#2
0
        public void ViewModelBase_GetCommandD_Test7()
        {
            var vm             = new MockViewModel();
            var commandInvoked = false;

            var cmd           = vm.InvokeGetCommandD <int>("Test", x => commandInvoked = true, x => false);
            var commandAssert = new CommandEventAssert(cmd);

            cmd.OnCanExecuteChanged();
            commandAssert.Expect();
            Assert.IsFalse(commandInvoked);
        }
示例#3
0
        public void ViewModelBase_GetCommandD_Test4()
        {
            var vm = new MockViewModel();

            try
            {
                vm.InvokeGetCommandD <int>("Test", null, x => false);
                Assert.Fail("Expected an exception");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("command", ex.ParamName);
            }
        }
示例#4
0
        public void ViewModelBase_GetCommandD_Test2()
        {
            var vm = new MockViewModel();

            try
            {
                vm.InvokeGetCommandD <int>("", x => { }, x => false);
                Assert.Fail("Expected an exception");
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("propertyName", ex.ParamName);
            }
        }
示例#5
0
        public void ViewModelBase_GetCommandD_Test1()
        {
            var vm             = new MockViewModel();
            var commandInvoked = false;

            var cmd = vm.InvokeGetCommandD <int>("Test", x => commandInvoked = true, x => false);

            Assert.IsFalse(commandInvoked);

            Assert.IsFalse(cmd.CanExecute(0));
            Assert.IsFalse(commandInvoked);

            cmd.Execute(0);
            Assert.IsTrue(commandInvoked);
        }
示例#6
0
        public void ViewModelBase_GetCommandD_Test6()
        {
            var vm             = new MockViewModel();
            var commandInvoked = false;

            ICommand cmd = vm.InvokeGetCommandD <int>("Test", x => commandInvoked = true, x => false);

            Assert.IsFalse(commandInvoked);

            try
            {
                cmd.Execute("X");
                Assert.Fail("Expected an exception");
            }
            catch (ArgumentException)
            {
                //OK
            }
        }