public void UndoAfterExecuteCommitTest() { //Arrange bool hasInnerExecute = false; bool hasInnerUndo = false; SwitchCommandMock mock = new SwitchCommandMock(); mock.OnInnerExecute += () => { return(hasInnerExecute = true); }; mock.OnInnerUndo += () => { return(hasInnerUndo = true); }; //Act bool executeResult = mock.Execute(); mock.Commit(); bool undoResult = mock.Undo(); //Assert Assert.IsTrue(executeResult); Assert.IsFalse(undoResult); Assert.IsTrue(hasInnerExecute); Assert.IsFalse(hasInnerUndo); }
public void DoubleCommitTest() { //Arrange int innerCommitCallCounter = 0; SwitchCommandMock mock = new SwitchCommandMock(); mock.OnInnerCommit += () => { innerCommitCallCounter++; return(true); }; //Act bool firstCommitResult = mock.Commit(); bool secondCommitResult = mock.Commit(); //Assert Assert.AreEqual(1, innerCommitCallCounter); Assert.IsTrue(firstCommitResult); Assert.IsFalse(secondCommitResult); }
public void CommitTest() { //Arrange bool hasInnerCommitExecuted = false; SwitchCommandMock mock = new SwitchCommandMock(); mock.OnInnerCommit += () => { return(hasInnerCommitExecuted = true); }; //Act bool commitResult = mock.Commit(); //Assert Assert.IsTrue(hasInnerCommitExecuted); Assert.IsTrue(commitResult); }
public void ExecuteAfterCommitTest() { //Arrange bool hasInnerExecuted = false; SwitchCommandMock mock = new SwitchCommandMock(); mock.OnInnerExecute += () => { return(hasInnerExecuted = true); }; //Act mock.Commit(); bool executeResult = mock.Execute(); //Assert Assert.IsFalse(executeResult); Assert.IsFalse(hasInnerExecuted); }