コード例 #1
0
        public void MultiDispatchCommandDoesNotExecutesInActiveRegisteredCommands()
        {
            CompositeCommand       activeAwareCommand = new CompositeCommand(true);
            MockActiveAwareCommand command            = new MockActiveAwareCommand();

            command.IsActive = false;
            activeAwareCommand.RegisterCommand(command);

            activeAwareCommand.Execute(null);

            Assert.IsFalse(command.WasExecuted);
        }
コード例 #2
0
        public void MultiDispatchCommandExecutesActiveRegisteredCommands()
        {
            CompositeCommand       activeAwareCommand = new CompositeCommand();
            MockActiveAwareCommand command            = new MockActiveAwareCommand();

            command.IsActive = true;
            activeAwareCommand.RegisterCommand(command);

            activeAwareCommand.Execute(null);

            Assert.IsTrue(command.WasExecuted);
        }
コード例 #3
0
        public void DispatchCommandShouldIgnoreInActiveCommandsInCanExecuteVote()
        {
            CompositeCommand       activeAwareCommand = new CompositeCommand(true);
            MockActiveAwareCommand commandOne         = new MockActiveAwareCommand()
            {
                IsActive = false, IsValid = false
            };
            MockActiveAwareCommand commandTwo = new MockActiveAwareCommand()
            {
                IsActive = true, IsValid = true
            };

            activeAwareCommand.RegisterCommand(commandOne);
            activeAwareCommand.RegisterCommand(commandTwo);

            Assert.IsTrue(activeAwareCommand.CanExecute(null));
        }
コード例 #4
0
        public void DispatchCommandDoesNotIncludeInActiveRegisteredCommandInVoting()
        {
            CompositeCommand       activeAwareCommand = new CompositeCommand(true);
            MockActiveAwareCommand command            = new MockActiveAwareCommand();

            activeAwareCommand.RegisterCommand(command);
            command.IsValid  = true;
            command.IsActive = false;

            Assert.IsFalse(activeAwareCommand.CanExecute(null), "Registered Command is inactive so should not participate in CanExecute vote");

            command.IsActive = true;

            Assert.IsTrue(activeAwareCommand.CanExecute(null));

            command.IsValid = false;

            Assert.IsFalse(activeAwareCommand.CanExecute(null));
        }
コード例 #5
0
        public void ActivityCausesActiveAwareCommandToRequeryCanExecute()
        {
            CompositeCommand       activeAwareCommand = new CompositeCommand(true);
            MockActiveAwareCommand command            = new MockActiveAwareCommand();

            activeAwareCommand.RegisterCommand(command);
            command.IsActive = true;

            bool globalCanExecuteChangeFired = false;

            activeAwareCommand.CanExecuteChanged += delegate
            {
                globalCanExecuteChangeFired = true;
            };


            Assert.IsFalse(globalCanExecuteChangeFired);
            command.IsActive = false;
            Assert.IsTrue(globalCanExecuteChangeFired);
        }
コード例 #6
0
        public void ShouldNotMonitorActivityIfUseActiveMonitoringFalse()
        {
            var mockCommand = new MockActiveAwareCommand();

            mockCommand.IsValid  = true;
            mockCommand.IsActive = true;
            var  nonActiveAwareCompositeCommand = new CompositeCommand(false);
            bool canExecuteChangedRaised        = false;

            nonActiveAwareCompositeCommand.RegisterCommand(mockCommand);
            nonActiveAwareCompositeCommand.CanExecuteChanged += delegate
            {
                canExecuteChangedRaised = true;
            };

            mockCommand.IsActive = false;

            Assert.IsFalse(canExecuteChangedRaised);

            nonActiveAwareCompositeCommand.Execute(null);

            Assert.IsTrue(mockCommand.WasExecuted);
        }
コード例 #7
0
        public void ShouldNotMonitorActivityIfUseActiveMonitoringFalse()
        {
            var mockCommand = new MockActiveAwareCommand();
            mockCommand.IsValid = true;
            mockCommand.IsActive = true;
            var nonActiveAwareCompositeCommand = new CompositeCommand(false);
            bool canExecuteChangedRaised = false;
            nonActiveAwareCompositeCommand.RegisterCommand(mockCommand);
            nonActiveAwareCompositeCommand.CanExecuteChanged += delegate
            {
                canExecuteChangedRaised = true;
            };

            mockCommand.IsActive = false;

            Assert.IsFalse(canExecuteChangedRaised);

            nonActiveAwareCompositeCommand.Execute(null);

            Assert.IsTrue(mockCommand.WasExecuted);
        }
コード例 #8
0
        public void ActivityCausesActiveAwareCommandToRequeryCanExecute()
        {
            CompositeCommand activeAwareCommand = new CompositeCommand(true);
            MockActiveAwareCommand command = new MockActiveAwareCommand();
            activeAwareCommand.RegisterCommand(command);
            command.IsActive = true;

            bool globalCanExecuteChangeFired = false;
            activeAwareCommand.CanExecuteChanged += delegate
                                                        {
                                                            globalCanExecuteChangeFired = true;
                                                        };


            Assert.IsFalse(globalCanExecuteChangeFired);
            command.IsActive = false;
            Assert.IsTrue(globalCanExecuteChangeFired);
        }
コード例 #9
0
        public void DispatchCommandShouldIgnoreInActiveCommandsInCanExecuteVote()
        {
            CompositeCommand activeAwareCommand = new CompositeCommand(true);
            MockActiveAwareCommand commandOne = new MockActiveAwareCommand() { IsActive = false, IsValid = false };
            MockActiveAwareCommand commandTwo = new MockActiveAwareCommand() { IsActive = true, IsValid = true };

            activeAwareCommand.RegisterCommand(commandOne);
            activeAwareCommand.RegisterCommand(commandTwo);

            Assert.IsTrue(activeAwareCommand.CanExecute(null));
        }
コード例 #10
0
        public void DispatchCommandDoesNotIncludeInActiveRegisteredCommandInVoting()
        {
            CompositeCommand activeAwareCommand = new CompositeCommand(true);
            MockActiveAwareCommand command = new MockActiveAwareCommand();
            activeAwareCommand.RegisterCommand(command);
            command.IsValid = true;
            command.IsActive = false;

            Assert.IsFalse(activeAwareCommand.CanExecute(null), "Registered Command is inactive so should not participate in CanExecute vote");

            command.IsActive = true;

            Assert.IsTrue(activeAwareCommand.CanExecute(null));

            command.IsValid = false;

            Assert.IsFalse(activeAwareCommand.CanExecute(null));

        }
コード例 #11
0
        public void MultiDispatchCommandDoesNotExecutesInActiveRegisteredCommands()
        {
            CompositeCommand activeAwareCommand = new CompositeCommand(true);
            MockActiveAwareCommand command = new MockActiveAwareCommand();
            command.IsActive = false;
            activeAwareCommand.RegisterCommand(command);

            activeAwareCommand.Execute(null);

            Assert.IsFalse(command.WasExecuted);
        }
コード例 #12
0
        public void MultiDispatchCommandExecutesActiveRegisteredCommands()
        {
            CompositeCommand activeAwareCommand = new CompositeCommand();
            MockActiveAwareCommand command = new MockActiveAwareCommand();
            command.IsActive = true;
            activeAwareCommand.RegisterCommand(command);

            activeAwareCommand.Execute(null);

            Assert.IsTrue(command.WasExecuted);
        }