public void ThrowsArgumentNullExceptionForNullCommand() { var vm = new CompositeCommandViewModel(); var commandManager = new CommandManager(); ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => commandManager.RegisterCommand("MyCommand", null)); }
public void ThrowsArgumentNullExceptionForWhitespaceCommandName() { var vm = new CompositeCommandViewModel(); var commandManager = new CommandManager(); ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => commandManager.RegisterCommand(" ", vm.TestCommand1)); }
public void RegistersCommandForExecution() { var vm = new CompositeCommandViewModel(); var compositeCommand = new CompositeCommand(); compositeCommand.RegisterCommand(vm.TestCommand1, vm); compositeCommand.Execute(); Assert.IsTrue(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 async Task AutomaticallyUnsubscribesCommandOnViewModelClosed() { var vm = new CompositeCommandViewModel(); var compositeCommand = new CompositeCommand(); compositeCommand.RegisterCommand(vm.TestCommand1, vm); Assert.IsFalse(vm.IsTestCommand1Executed); await vm.CloseViewModelAsync(false); compositeCommand.Execute(); Assert.IsFalse(vm.IsTestCommand1Executed); }
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); }