public void DomainDataSourceCommand()
        {
            bool canExecute = false;
            bool executed = false;

            DomainDataSource dds = new DomainDataSource();
            DomainDataSourceCommand command = new DomainDataSourceCommand(dds, "Mock", () => canExecute, () => executed = true);

            // Test CanExecute
            Assert.AreEqual(canExecute, command.CanExecute(null),
                "Command should not be executable.");

            canExecute = true;

            Assert.AreEqual(canExecute, command.CanExecute(null),
                "Command should be executable.");

            // Test Execute
            Assert.IsFalse(executed,
                "Command should not have been executed.");

            command.Execute(null);

            Assert.IsTrue(executed,
                "Command should have been executed.");

            // Test Execute exception
            canExecute = false;
            executed = false;

            ExceptionHelper.ExpectException<InvalidOperationException>(() => command.Execute(null));
            Assert.IsFalse(executed,
                "Command should not have been executed after failure.");
        }
Beispiel #2
0
        public void DomainDataSourceCommand()
        {
            bool canExecute = false;
            bool executed   = false;

            DomainDataSource        dds     = new DomainDataSource();
            DomainDataSourceCommand command = new DomainDataSourceCommand(dds, "Mock", () => canExecute, () => executed = true);

            // Test CanExecute
            Assert.AreEqual(canExecute, command.CanExecute(null),
                            "Command should not be executable.");

            canExecute = true;

            Assert.AreEqual(canExecute, command.CanExecute(null),
                            "Command should be executable.");

            // Test Execute
            Assert.IsFalse(executed,
                           "Command should not have been executed.");

            command.Execute(null);

            Assert.IsTrue(executed,
                          "Command should have been executed.");

            // Test Execute exception
            canExecute = false;
            executed   = false;

            ExceptionHelper.ExpectException <InvalidOperationException>(() => command.Execute(null));
            Assert.IsFalse(executed,
                           "Command should not have been executed after failure.");
        }