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/71d7202c8118beb6e12cf0fa2ec8200e to your computer and use it in GitHub Desktop.
Save es-repo/71d7202c8118beb6e12cf0fa2ec8200e to your computer and use it in GitHub Desktop.
Test Case
static object[] BoxAndLabelsAndThings_OpenBoxThenPutThingInsideThenCloseBoxAndWriteLogs_ThingsWithLabelEndedWithIgnoreExpected_1()
{
var writeLogMock = new Mock<WriteLog>(MockBehavior.Strict);
var boxMock = new Mock<IBox>(MockBehavior.Strict);
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."));
var args = new Args
{
Box = boxMock.Object,
LabelsAndThings = new Dictionary<string, Thing>
{
{ "Label 1", new Thing { Size = 1 } },
{ "Label 2 Ignore", new Thing { Size = 2 } },
{ "Label 3", new Thing { Size = 3 } },
},
WriteLog = writeLogMock.Object
};
var expected = new Dictionary<string, Thing>
{
{ "Label 2 Ignore", new Thing { Size = 2 } },
};
return new object[] { args, expected };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment