Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save es-repo/ea1b52633242b17cab48adbcd1047e85 to your computer and use it in GitHub Desktop.
Save es-repo/ea1b52633242b17cab48adbcd1047e85 to your computer and use it in GitHub Desktop.
better-unit-test-in-c#-article-mock-sequences.cs
var mockSequence = new MockSequence();
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