Skip to content

Instantly share code, notes, and snippets.

@es-repo
es-repo / better-unit-test-in-c#-article-PutInsideTest-TestCases.cs
Last active May 22, 2022 21:35
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();
}
@es-repo
es-repo / better-unit-test-in-c#-article-Box-v2.cs
Created May 22, 2022 21:25
better-unit-test-in-c#-article-Box-v2.cs
public sealed record Box
{
...
public bool IsOpen { get; internal set; }
internal Box(Dictionary<string, Thing> thingsInside)
{
this.thingsInside = thingsInside;
}
...
@es-repo
es-repo / better-unit-test-in-c#-article-Box-Equals.cs.cs
Created May 22, 2022 21:22
better-unit-test-in-c#-article-Box-Equals.cs
public sealed record Box
{
...
public bool Equals(Box? other)
{
if (other == null)
{
return false;
}
@es-repo
es-repo / better-unit-test-in-c#-article-PutInsideTest-v1.cs
Created May 22, 2022 21:14
better-unit-test-in-c#-article-PutInsideTest-v1.cs
public static class PutInsideTest
{
public sealed record Args
{
public Thing Thing { get; init; } = null!;
public string Label { get; init; } = "";
}
sealed class TestCases : IEnumerable<object[]>
{
@es-repo
es-repo / better-unit-test-in-c#-article-csproj.xml
Created May 22, 2022 20:54
better-unit-test-in-c#-article-csproj.xml
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(AssemblyName).Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
@es-repo
es-repo / better-unit-test-in-c#-article-Box-v1.cs
Last active May 22, 2022 20:58
better-unit-test-in-c#-article-Box-v1.cs
public sealed record Box
{
private readonly Dictionary<string, Thing> thingsInside;
public int Size { get; init; }
public bool IsOpen { get; private set; }
public Box()
{

Keybase proof

I hereby claim:

  • I am es-repo on github.
  • I am eugenes1 (https://keybase.io/eugenes1) on keybase.
  • I have a public key ASBedi-IeSY75DVAptVtNaRRquM22bADwImvRj_2jUl_5Qo

To claim this, I am signing this object: