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 += new Action<object>((object parameter) => secondCommand.IsActive = false); var compositeCommand = new CompositeCommand(true); compositeCommand.RegisterCommand(firstCommand); compositeCommand.RegisterCommand(secondCommand); compositeCommand.Execute(null); Assert.True(secondCommand.WasExecuted); }
public void MultiDispatchCommandDoesNotExecutesInactiveRegisteredCommands() { CompositeCommand activeAwareCommand = new CompositeCommand(true); MockActiveAwareCommand command = new MockActiveAwareCommand(); command.IsActive = false; activeAwareCommand.RegisterCommand(command); activeAwareCommand.Execute(null); Assert.False(command.WasExecuted); }
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.False(canExecuteChangedRaised); nonActiveAwareCompositeCommand.Execute(null); Assert.True(mockCommand.WasExecuted); }
public void MultiDispatchCommandExecutesActiveRegisteredCommands() { CompositeCommand activeAwareCommand = new CompositeCommand(); MockActiveAwareCommand command = new MockActiveAwareCommand(); command.IsActive = true; activeAwareCommand.RegisterCommand(command); activeAwareCommand.Execute(null); Assert.True(command.WasExecuted); }