This file contains hidden or 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
public static class FillBoxTest | |
{ | |
public sealed record Args | |
{ | |
public IBox Box { get; init; } = null!; | |
public Dictionary<string, Thing> LabelsAndThings { get; init; } = new(); | |
public WriteLog WriteLog { get; init; } = null!; | |
} | |
sealed class TestCases : IEnumerable<object[]> |
This file contains hidden or 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
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); |
This file contains hidden or 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 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.")); |
This file contains hidden or 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.")); |
This file contains hidden or 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); |
This file contains hidden or 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
sealed class TestCases : IEnumerable<object[]> | |
{ | |
public IEnumerator<object[]> GetEnumerator() | |
{ | |
yield return BoxAndLabelsAndThings_OpenBoxThenPutThingInsideThenCloseBoxAndWriteLogs_ThingsWithLabelEndedWithIgnoreExpected_1(); | |
} | |
static object[] BoxAndLabelsAndThings_OpenBoxThenPutThingInsideThenCloseBoxAndWriteLogs_ThingsWithLabelEndedWithIgnoreExpected_1() | |
{ | |
... |
This file contains hidden or 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
public static class FillBoxTest | |
{ | |
public sealed record Args | |
{ | |
public IBox Box { get; init; } = null!; | |
public Dictionary<string, Thing> LabelsAndThings { get; init; } = new(); | |
public WriteLog WriteLog { get; init; } = null!; | |
} | |
sealed class TestCases : IEnumerable<object[]> |
This file contains hidden or 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
public static class Operations | |
{ | |
public static Dictionary<string, Thing> FillBox( | |
IBox box, | |
IDictionary<string, Thing> labelsAndThings, | |
WriteLog writeLog) | |
{ | |
var rest = new Dictionary<string, Thing>(); | |
box.Open(); | |
writeLog("The box is opened."); |
This file contains hidden or 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
public interface IBox | |
{ | |
int Size { get; } | |
void Open(); | |
void Close(); | |
bool PutInside(Thing thing, string label); | |
} | |
public delegate void WriteLog(string message); |
This file contains hidden or 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
public static class PutInsideTest | |
{ | |
public sealed record Args | |
{ | |
public Thing Thing { get; init; } = null!; | |
public string Label { get; init; } = ""; | |
} | |
sealed class TestCases : IEnumerable<object[]> | |
{ |
NewerOlder