Exemplo n.º 1
0
            public void RegistersCommandForExecution()
            {
                var vm = new CompositeCommandViewModel();
                var compositeCommand = new CompositeCommand(); 

                compositeCommand.RegisterCommand(vm.TestCommand1, vm);

                compositeCommand.Execute();

                Assert.IsTrue(vm.IsTestCommand1Executed);
            }
Exemplo n.º 2
0
            public void RegistersActionForExecution()
            {
                var compositeCommand = new CompositeCommand();

                bool executed = false;
                var action = new Action<object>(obj => executed = true);

                compositeCommand.RegisterAction(action);
                compositeCommand.Execute();

                Assert.IsTrue(executed);
            }
            public void RegisteredActionsCanBeUnregistered_DynamicAction()
            {
                var compositeCommand = new CompositeCommand();

                compositeCommand.RegisterAction(RegisteredActionsCanBeUnregistered_TestMethod);
                compositeCommand.UnregisterAction(RegisteredActionsCanBeUnregistered_TestMethod);

                compositeCommand.Execute(null);

                Assert.IsFalse(_registeredActionsCanBeUnregistered_TestValue);
            }
Exemplo n.º 4
0
            public async void AutomaticallyUnsubscribesCommandOnViewModelClosed()
            {
                var vm = new CompositeCommandViewModel();
                var compositeCommand = new CompositeCommand();

                compositeCommand.RegisterCommand(vm.TestCommand1, vm);

                Assert.IsFalse(vm.IsTestCommand1Executed);

                await vm.CloseViewModel(false);

                compositeCommand.Execute();

                Assert.IsFalse(vm.IsTestCommand1Executed);
            }
            public void RegisteredActionsCanBeUnregistered_DefinedAction()
            {
                var invoked = false;
                Action action = () => invoked = true;

                var compositeCommand = new CompositeCommand();

                compositeCommand.RegisterAction(action);
                compositeCommand.UnregisterAction(action);

                compositeCommand.Execute(null);

                Assert.IsFalse(invoked);
            }