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(); }
public void DoubleCommitTest() { //Arrange ICommand innerCommand = MockRepository.GenerateStrictMock <ICommand>(); innerCommand.Expect(ic => ic.Commit()). Repeat.Once(). Return(true); SwitchCommand command = new SwitchCommand(innerCommand); //Act bool commitResult = command.Commit(); bool secondCommitResult = command.Commit(); //Assert Assert.IsTrue(commitResult); Assert.IsFalse(secondCommitResult); innerCommand.VerifyAllExpectations(); }