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); }
public void MultiDispatchCommandExecutesActiveRegisteredCommands() { CompositeCommand activeAwareCommand = new CompositeCommand(); MockActiveAwareCommand command = new MockActiveAwareCommand(); command.IsActive = true; activeAwareCommand.RegisterCommand(command); activeAwareCommand.Execute(null); Assert.IsTrue(command.WasExecuted); }
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)); }
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); }
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 Click 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)); }
public void UnregisterCommandDisconnectsIsActiveChangedDelegate() { CompositeCommand activeAwareCommand = new CompositeCommand(true); MockActiveAwareCommand commandOne = new MockActiveAwareCommand() { IsActive = true, IsValid = true }; MockActiveAwareCommand commandTwo = new MockActiveAwareCommand() { IsActive = false, IsValid = false }; activeAwareCommand.RegisterCommand(commandOne); activeAwareCommand.RegisterCommand(commandTwo); Assert.IsTrue(activeAwareCommand.CanExecute(null)); activeAwareCommand.UnregisterCommand(commandOne); Assert.IsFalse(activeAwareCommand.CanExecute(null)); }
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.IsTrue(secondCommand.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.IsFalse(canExecuteChangedRaised); nonActiveAwareCompositeCommand.Execute(null); Assert.IsTrue(mockCommand.WasExecuted); }
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 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 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.False(globalCanExecuteChangeFired); command.IsActive = false; Assert.True(globalCanExecuteChangeFired); }
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.True(activeAwareCommand.CanExecute(null)); }
public void DispatchCommandDoesNotIncludeInactiveRegisteredCommandInVoting() { CompositeCommand activeAwareCommand = new CompositeCommand(true); MockActiveAwareCommand command = new MockActiveAwareCommand(); activeAwareCommand.RegisterCommand(command); command.IsValid = true; command.IsActive = false; Assert.False(activeAwareCommand.CanExecute(null), "Registered Click is inactive so should not participate in CanExecute vote"); command.IsActive = true; Assert.True(activeAwareCommand.CanExecute(null)); command.IsValid = false; Assert.False(activeAwareCommand.CanExecute(null)); }
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 MultiDispatchCommandExecutesActiveRegisteredCommands() { CompositeCommand activeAwareCommand = new CompositeCommand(); MockActiveAwareCommand command = new MockActiveAwareCommand(); command.IsActive = true; activeAwareCommand.RegisterCommand(command); activeAwareCommand.Execute(null); Assert.True(command.WasExecuted); }
public void UnregisterCommandDisconnectsIsActiveChangedDelegate() { CompositeCommand activeAwareCommand = new CompositeCommand(true); MockActiveAwareCommand commandOne = new MockActiveAwareCommand() { IsActive = true, IsValid = true }; MockActiveAwareCommand commandTwo = new MockActiveAwareCommand() { IsActive = false, IsValid = false }; activeAwareCommand.RegisterCommand(commandOne); activeAwareCommand.RegisterCommand(commandTwo); Assert.True(activeAwareCommand.CanExecute(null)); activeAwareCommand.UnregisterCommand(commandOne); Assert.False(activeAwareCommand.CanExecute(null)); }