Last active
July 28, 2022 22:04
-
-
Save es-repo/3dd924bf3f89c962ab6a23b5b3275e31 to your computer and use it in GitHub Desktop.
better-unit-test-in-c#-article-mock-sequence.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var writeLogMock = new Mock<WriteLog>(MockBehavior.Strict); | |
var boxMock = new Mock<IBox>(MockBehavior.Strict); | |
boxMock.InSequence(mockSequence).Setup(box => box.Open()); | |
writeLogMock.InSequence(mockSequence).Setup(writeLog => writeLog("The box is opened.")); | |
boxMock.InSequence(mockSequence).Setup(box => box.PutInside(new Thing { Size = 1 }, "Label 1")).Returns(true); | |
boxMock.InSequence(mockSequence).Setup(box => box.PutInside(new Thing { Size = 2 }, "Label 2 Ignore")).Returns(false); | |
boxMock.InSequence(mockSequence).Setup(box => box.PutInside(new Thing { Size = 3 }, "Label 3")).Returns(true); | |
boxMock.InSequence(mockSequence).Setup(box => box.Close()); | |
writeLogMock.InSequence(mockSequence).Setup(writeLog => writeLog("The box is closed.")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment