Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kbrashears5/net-standard-test-helper

Collection of helpers for unit testing with Net Standard
https://github.com/kbrashears5/net-standard-test-helper

assert helper netstandard nunit test xunit

Last synced: 17 days ago
JSON representation

Collection of helpers for unit testing with Net Standard

Awesome Lists containing this project

README

        

Net Standard Test Helpers



Collection of helpers for unit testing with Net Standard

[![Build Status](https://dev.azure.com/kbrashears5/github/_apis/build/status/kbrashears5.net-standard-test-helper?branchName=master)](https://dev.azure.com/kbrashears5/github/_build/latest?definitionId=5&branchName=master)
[![Tests](https://img.shields.io/azure-devops/tests/kbrashears5/github/4)](https://img.shields.io/azure-devops/tests/kbrashears5/github/4)
[![Code Coverage](https://img.shields.io/azure-devops/coverage/kbrashears5/github/4)](https://img.shields.io/azure-devops/coverage/kbrashears5/github/4)

[![nuget](https://img.shields.io/nuget/v/NetStandardTestHelper.svg)](https://www.nuget.org/packages/NetStandardTestHelper/)
[![nuget](https://img.shields.io/nuget/dt/NetStandardTestHelper)](https://img.shields.io/nuget/dt/NetStandardTestHelper)

## 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:
```c#
Class.Function(TestValues.EmptyString);
```
instead of
```c#
Class.Function(null);
```

### Xunit
```c#
[Fact]
public void Test()
{
var ex = Assert.Throws(() => Class.Function(null));

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

### Nunit
```c#
[TestCase]
public void Test()
{
var ex = Assert.Throws(() => Class.Function(null));

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