public CreateCommand ( string commandName, Catel.Windows.Input.InputGesture inputGesture = null, ICompositeCommand compositeCommand = null, bool throwExceptionWhenCommandIsAlreadyCreated = true ) : void | ||
commandName | string | Name of the command. |
inputGesture | Catel.Windows.Input.InputGesture | The input gesture. |
compositeCommand | ICompositeCommand | The composite command. If |
throwExceptionWhenCommandIsAlreadyCreated | bool | if set to |
Результат | void |
public void ThrowsInvalidOperationExceptionForAlreadyCreatedCommand() { var commandManager = new CommandManager(); commandManager.CreateCommand("MyCommand"); ExceptionTester.CallMethodAndExpectException<InvalidOperationException>(() => commandManager.CreateCommand("MyCommand")); }
public void ReturnsTrueForCreatedCommand() { var commandManager = new CommandManager(); commandManager.CreateCommand("MyCommand"); Assert.IsTrue(commandManager.IsCommandCreated("MyCommand")); }
public void CorrectlyCreatesTheCommand() { var commandManager = new CommandManager(); commandManager.CreateCommand("MyCommand"); Assert.IsTrue(commandManager.IsCommandCreated("MyCommand")); }
public void ThrowsArgumentNullExceptionForWhitespaceCommandName() { var commandManager = new CommandManager(); ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => commandManager.CreateCommand(" ")); }
public void DoesNotExecuteUnregisteredCommands() { var vm = new CompositeCommandViewModel(); var commandManager = new CommandManager(); commandManager.CreateCommand("MyCommand"); commandManager.RegisterCommand("MyCommand", vm.TestCommand1); Assert.IsTrue(commandManager.IsCommandCreated("MyCommand")); commandManager.UnregisterCommand("MyCommand", vm.TestCommand1); commandManager.ExecuteCommand("MyCommand"); Assert.IsFalse(vm.IsTestCommand1Executed); }
public void ExecutesRegisteredCommands() { var vm = new CompositeCommandViewModel(); var commandManager = new CommandManager(); commandManager.CreateCommand("MyCommand"); commandManager.RegisterCommand("MyCommand", vm.TestCommand1); commandManager.ExecuteCommand("MyCommand"); Assert.IsTrue(vm.IsTestCommand1Executed); }
public void ReturnsCommandForCreatedCommand() { var commandManager = new CommandManager(); commandManager.CreateCommand("MyCommand"); Assert.IsNotNull(commandManager.GetCommand("MyCommand")); }
public void RegisteredActionsCanBeUnregistered_DynamicAction() { var commandManager = new CommandManager(); commandManager.CreateCommand("TestAction"); commandManager.RegisterAction("TestAction", RegisteredActionsCanBeUnregistered_TestMethod); commandManager.UnregisterAction("TestAction", RegisteredActionsCanBeUnregistered_TestMethod); commandManager.ExecuteCommand("TestAction"); Assert.IsFalse(_registeredActionsCanBeUnregistered_TestValue); }
public void RegisteredActionsCanBeUnregistered_DefinedAction() { var invoked = false; Action action = () => invoked = true; var commandManager = new CommandManager(); commandManager.CreateCommand("TestAction"); commandManager.RegisterAction("TestAction", action); commandManager.UnregisterAction("TestAction", action); commandManager.ExecuteCommand("TestAction"); Assert.IsFalse(invoked); }