Beispiel #1
0
        public void ShouldIgnoreChangesToIsActiveDuringExecution()
        {
            var firstCommand = new MockActiveAwareCommand {
                IsActive = true
            };
            var secondCommand = new MockActiveAwareCommand {
                IsActive = true
            };

            // During execution set the second command to inactive, this should not affect the currently executed selection.
            firstCommand.ExecuteAction += (object _) => secondCommand.IsActive = false;

            var compositeCommand = new CompositeCommand(true);

            compositeCommand.RegisterCommand(firstCommand);
            compositeCommand.RegisterCommand(secondCommand);
            compositeCommand.Execute(null);

            Assert.True(secondCommand.WasExecuted);
        }
Beispiel #2
0
        public void ShouldNotMonitorActivityIfUseActiveMonitoringFalse()
        {
            var mockCommand = new MockActiveAwareCommand {
                IsValid = true, IsActive = true
            };
            var  nonActiveAwareCompositeCommand = new CompositeCommand(false);
            bool canExecuteChangedRaised        = false;

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

            mockCommand.IsActive = false;

            Assert.False(canExecuteChangedRaised);

            nonActiveAwareCompositeCommand.Execute(null);

            Assert.True(mockCommand.WasExecuted);
        }