Skip to content

kbrashears5/net-standard-test-helper

Repository files navigation

Net Standard Test Helpers

Collection of helpers for unit testing with Net Standard

Build Status Tests Code Coverage

nuget nuget

Usage

Use the static class TestHelper to help assert guard clause, exceptions, and more.

Test Values

Use the static class TestValues to use some common objects in a way that doesn't clutter your testing, and let your code be your comments for your tests. Pass the following to your functions:

Class.Function(TestValues.EmptyString);

instead of

Class.Function(null);

Xunit

[Fact]
public void Test()
{
    var ex = Assert.Throws<ArgumentNullException>(() => Class.Function(null));

    TestHelper.AssertArgumentNullException(exception: exception,
        parameterName: "parameterName");
}

Nunit

[TestCase]
public void Test()
{
    var ex = Assert.Throws<ArgumentNullException>(() => Class.Function(null));

    TestHelper.AssertArgumentNullException(exception: exception,
        parameterName: "parameterName");
}