示例#1
0
        public void UndoAfterExecuteCommitTest()
        {
            //Arrange
            ICommand innerCommand = MockRepository.GenerateStrictMock <ICommand>();

            innerCommand.Expect(ic => ic.Execute()).
            Repeat.Once().
            Return(true);
            innerCommand.Expect(ic => ic.Commit()).
            Repeat.Once().
            Return(true);
            innerCommand.Expect(ic => ic.Undo()).
            Repeat.Never();

            SwitchCommand command = new SwitchCommand(innerCommand);

            //Act
            bool execteResult = command.Execute();
            bool commitResult = command.Commit();
            bool undoResult   = command.Undo();

            //Assert
            Assert.IsTrue(execteResult);
            Assert.IsTrue(commitResult);
            Assert.IsFalse(undoResult);

            innerCommand.VerifyAllExpectations();
        }
示例#2
0
        public void UndoWithoutExecuteTest()
        {
            //Arrange
            ICommand innerCommand = MockRepository.GenerateStrictMock <ICommand>();

            innerCommand.Expect(ic => ic.Undo()).
            Repeat.Never();

            SwitchCommand command = new SwitchCommand(innerCommand);

            //Act
            bool undoResult = command.Undo();

            //Assert
            Assert.IsFalse(undoResult);

            innerCommand.VerifyAllExpectations();
        }