예제 #1
0
            public void ThrowsArgumentNullExceptionForNullCommand()
            {
                var vm             = new CompositeCommandViewModel();
                var commandManager = new CommandManager();

                ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => commandManager.RegisterCommand("MyCommand", null));
            }
예제 #2
0
            public void ThrowsArgumentNullExceptionForWhitespaceCommandName()
            {
                var vm             = new CompositeCommandViewModel();
                var commandManager = new CommandManager();

                ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => commandManager.RegisterCommand(" ", vm.TestCommand1));
            }
예제 #3
0
            public void RegistersCommandForExecution()
            {
                var vm = new CompositeCommandViewModel();
                var compositeCommand = new CompositeCommand();

                compositeCommand.RegisterCommand(vm.TestCommand1, vm);

                compositeCommand.Execute();

                Assert.IsTrue(vm.IsTestCommand1Executed);
            }
예제 #4
0
            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);
            }
예제 #5
0
            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);
            }
예제 #6
0
            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);
            }