A set of nugets to allow for easier testing of dotnet code using xUnit
Install-Package Frank.Testing
dotnet add package Frank.Testing
using Xunit;
using Xunit.Abstractions;
public class MyTestClass
{
private readonly ITestOutputHelper _outputHelper;
public MyTestClass(ITestOutputHelper outputHelper)
{
_outputHelper = outputHelper;
}
[Fact]
public void MyTestMethod()
{
_outputHelper.WriteLine(new { MyProperty = "MyValue" }); // Writes to test output as JSON: {"MyProperty":"MyValue"}
_outputHelper.WriteJson(new { MyProperty = "MyValue" }); // Writes to test output as JSON: {"MyProperty":"MyValue"}
}
[Fact]
public void MyTestMethod2()
{
_outputHelper.WriteCSharp(new { MyProperty = "MyValue" }); // Writes to test output as C#: var anonymousType = new { MyProperty = "MyValue" };
}
[Fact]
public void MyTestMethod3()
{
_outputHelper.WriteXml(new MyClass() { Name = "MyName" }); // Writes to test output as XML: <MyClass><Name>MyName</Name></MyClass>
}
}