Skip to content

Instantly share code, notes, and snippets.

@stiano
Last active April 3, 2021 12:13
Show Gist options
  • Save stiano/ce26652d5e1997344f2afeb1213759ea to your computer and use it in GitHub Desktop.
Save stiano/ce26652d5e1997344f2afeb1213759ea to your computer and use it in GitHub Desktop.
NUnit testing dependencies
public static class TestExtensions
{
private static readonly JsonSerializerOptions JsonSerializerOptions = new JsonSerializerOptions()
{
WriteIndented = true,
};
public static void ToConsole(this object? o)
{
if (o is null)
return;
var json = ToJson(o);
Console.WriteLine(json);
}
public static string ToJson(this object? o)
{
if (o is null)
return string.Empty;
return JsonSerializer.Serialize(o, JsonSerializerOptions);
}
}
<ItemGroup>
<PackageReference Include="nunit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="System.Runtime.Serialization.Json" Version="4.3.0" />
</ItemGroup>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment