Skip to content

Latest commit

 

History

History
70 lines (53 loc) · 2.18 KB

README.md

File metadata and controls

70 lines (53 loc) · 2.18 KB

Frank.Testing

A set of nugets to allow for easier testing of dotnet code using xUnit


GitHub License NuGet NuGet

GitHub contributors GitHub Release Date - Published_At GitHub last commit GitHub commit activity GitHub pull requests GitHub issues GitHub closed issues


Installation

NuGet

Install-Package Frank.Testing

.NET CLI

dotnet add package Frank.Testing

Usage

TestOutputHelperExtensions

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>
    }
}