Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save es-repo/0b5c6ef58d22d77dbb67ad8323c67990 to your computer and use it in GitHub Desktop.

Select an option

Save es-repo/0b5c6ef58d22d77dbb67ad8323c67990 to your computer and use it in GitHub Desktop.
better-unit-test-in-c#-article-PutInsideTest-TestCases .cs
sealed class TestCases : IEnumerable<object[]>
{
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public IEnumerator<object[]> GetEnumerator()
{
yield return OpenBox_ThingWithSizeLessThanAvailableSpace_UniqueLabel_ThingAddedIntoBox_TrueExpected_1();
yield return ClosedBox_ThingWithSizeLessThanAvailableSpace_UniqueLabel_ThingNotAddedIntoBox_FalseExpected_2();
}
static object[] OpenBox_ThingWithSizeLessThanAvailableSpace_UniqueLabel_ThingAddedIntoBox_TrueExpected_1()
{
var stateActual = new Box(
new Dictionary<string, Thing>
{
{ "Label1", new Thing { Size = 10 } },
{ "Label2", new Thing { Size = 20 } },
})
{
Size = 100,
IsOpen = true
};
var args = new Args
{
Thing = new Thing { Size = 30 },
Label = "Label3"
};
var stateExpected = new Box(new Dictionary<string, Thing>
{
{ "Label1", new Thing { Size = 10 } },
{ "Label2", new Thing { Size = 20 } },
{ "Label3", new Thing { Size = 30 } },
})
{
Size = 100,
IsOpen = true
};
var expected = true;
return new object[] { stateActual, args, stateExpected, expected };
}
static object[] ClosedBox_ThingWithSizeLessThanAvailableSpace_UniqueLabel_ThingNotAddedIntoBox_FalseExpected_2()
{
var stateActual = new Box(
new Dictionary<string, Thing>
{
{ "Label1", new Thing { Size = 10 } },
{ "Label2", new Thing { Size = 20 } },
})
{
Size = 100,
IsOpen = false
};
var args = new Args
{
Thing = new Thing { Size = 30 },
Label = "Label3"
};
var stateExpected = new Box(
new Dictionary<string, Thing>
{
{ "Label1", new Thing { Size = 10 } },
{ "Label2", new Thing { Size = 20 } },
})
{
Size = 100,
IsOpen = false
};
var expected = true;
return new object[] { stateActual, args, stateExpected, expected };
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment