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/c2ed03ec01115d655be3df8346f55534 to your computer and use it in GitHub Desktop.
Save es-repo/c2ed03ec01115d655be3df8346f55534 to your computer and use it in GitHub Desktop.
better-unit-test-in-c#-article-FillBoxTest-layout.cs
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[]>
{
...
}
[Theory]
[ClassData(typeof(TestCases))]
public static void Test(
Args args,
Dictionary<string, Thing> expected)
{
var actual = Operations.FillBox(args.Box, args.LabelsAndThings, args.WriteLog);
Assert.Equal(expected, actual);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment