SparkyTestHelpers
Tags: csharp, dotnet, testing, unittesting
Published: 2020-02-17 02:00:11

The [SparkyTestHelpers](https://www.nuget.org/packages?q=sparkytesthelpers) are a set of .NET unit test helper tools I've created and published via NuGet. My hope is that they make unit testing easier. 

Easier tests = More tests = Better code.

The tools are "test framework agnostic" - You can use them with MSTest, NUnit, XUnit, etc.

<table style="border-collapse: collapse">

<tr><td colspan="2"><h2>SparkyTestHelpers: Exceptions</h2></td></tr>
<tr>
<td>Helpers for asserting that expected exceptions are thrown (and that unexpected exceptions aren't!)</td>
<td><img src="https://dev-to-uploads.s3.amazonaws.com/i/tz8uqbxizx4vhwz56njz.jpg" /></td>
<tr><td colspan="2">
<a href="https://www.nuget.org/packages/SparkyTestHelpers/">nuget</a> | 
<a href="https://dev.to/sparky/unit-testing-net-exceptions-1mnm#a-better-way">details</a>
</td></tr>

<tr><td colspan="2"><h2>SparkyTestHelpers: Scenarios</h2></td></tr>
<tr>
<td>Provides the ability to execute the same test code for multiple test cases and, after all test cases have been executed, fail the unit test if any of the test cases failed.</td>
<td style="width: 250px"><img src="https://dev-to-uploads.s3.amazonaws.com/i/y88ayhnen5o8iwo9bk87.jpg" /></td>
<tr><td colspan="2">
<a href="https://www.nuget.org/packages/SparkyTestHelpers/">nuget</a> | 
<a href="https://dev.to/sparky/sparkytesthelpers-scenarios-57f2">details</a>
</td></tr>

<tr><td colspan="2"><h2>SparkyTestHelpers: AppSettings</h2></td></tr>
<tr>
<td>Unit test helpers for "appSettings" values in XML .config files.</td>
<td><img src="https://dev-to-uploads.s3.amazonaws.com/i/vrlv09k7lioyl1fbt31n.jpg" /></td>
<tr><td colspan="2">
<a href="https://www.nuget.org/packages/SparkyTestHelpers.AppSettings/">nuget</a> | 
<a href="https://dev.to/sparky/sparkytesthelpers-appsettings-178n">details</a>
</td></tr>

<tr><td colspan="2"><h2>SparkyTestHelpers: Moq</h2></td></tr>
<tr>
<td>Unit test syntax helpers for the Moq mocking framework.</td>
<td><img src="https://dev-to-uploads.s3.amazonaws.com/i/yc2xx3oqpc4imz504mje.jpg" /></td>
<tr><td colspan="2">
<a href="https://www.nuget.org/packages/SparkyTestHelpers.Moq.Fluent/">nuget</a> | 
<a href="https://dev.to/sparky/sparkytesthelpers-moq-307h">details</a>
</td></tr>

<tr><td colspan="2"><h2>SparkyTestHelpers: Mapping/AutoMapper</h2></td></tr>
<tr>
<td>Helpers for testing that properties were successfully "mapped" from one type to another, either via AutoMapper or another automatic mapping framework, or by hand-written "destination.X = source.X;" code.</td>
<td><img src="https://dev-to-uploads.s3.amazonaws.com/i/56yopvvnjg0upn3amth4.jpg" /></td>
<tr><td colspan="2">
<a href="https://www.nuget.org/packages/SparkyTestHelpers.AutoMapper/">nuget</a> | 
<a href="https://dev.to/sparky/sparkytesthelpers-mapping-automapper-48c1">details</a>
</td></tr>

<tr><td colspan="2"><h2>SparkyTestHelpers: Populater</h2></td></tr>
<tr>
<td>This package provides tools for auto-populating class instance properties for testing purposes, usually with random values.</td>
<td><img src="https://dev-to-uploads.s3.amazonaws.com/i/g1mvpfc1jw813kwas7wa.jpg" /></td>
<tr><td colspan="2">
<a href="https://www.nuget.org/packages/SparkyTestHelpers.Populater/">nuget</a> 
| <a href="https://dev.to/sparky/sparkytesthelpers-populater-2ljf">details</a>
</td></tr>

<tr><td colspan="2"><h2>SparkyTestHelpers: XML</h2></td></tr>
<tr>
<td>Helpers to perform .config file XML transformations, and to test the resulting transformed XML (or actually any XML, whether it's .config format or not).</td>
<td><img src="https://dev-to-uploads.s3.amazonaws.com/i/8mj99y6x15v1aobjzz8c.jpg" /></td>
<tr><td colspan="2">
<a href="https://www.nuget.org/packages/SparkyTestHelpers.Xml/">nuget</a> | 
<a href="https://dev.to/sparky/sparkytesthelpers-xml-9dh">details</a>
</td></tr>

<tr><td colspan="2"><h2>SparkyTestHelpers: DataAnnotations</h2></td></tr>
<tr>
<td>Helper classes to enable a fluent syntax for unit testing of .NET models and entities that use System.ComponentModel.DataAnnotations ValidationAttributes.</td>
<td><img src="https://dev-to-uploads.s3.amazonaws.com/i/tfto5btwgyof5r0hsr4k.jpg" /></td>
<tr><td colspan="2">
<a href="https://www.nuget.org/packages/SparkyTestHelpers.DataAnnotations/">nuget</a> | 
<a href="https://dev.to/sparky/sparkytesthelpers-dataannotations-5c1j">details</a>
</td></tr>

<tr><td colspan="2"><h2>SparkyTestHelpers: AspNetMvc</h2></td></tr>
<tr>
<td>These NuGet packages (one for the “classic” ASP.NET MVC Framework and one for ASP.NET Core MVC) contain helpers for testing that MVC controller actions return expected results, and for testing routing rules.</td>
<td><img src="https://dev-to-uploads.s3.amazonaws.com/i/u4u9ytin400yomsxn6xe.jpg" /></td>
<tr><td colspan="2">
<a href="https://www.nuget.org/packages/SparkyTestHelpers.AspNetMvc/">nuget</a> | 
<a href="https://dev.to/sparky/sparkytesthelpers-aspnetmvc-1pc8">details</a>
</td></tr>

<tr><td colspan="2"><h2>How to test C# private methods / SparkyTestHelpers.NonPublic</h2></td></tr>
<tr>
<td>You shouldn't - But if you do, here's how</td>
<td><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ufsmrec64tr4ms3r0te3.png" /></td>
<tr><td colspan="2">
<a href="https://www.nuget.org/packages/SparkyTestHelpers.NonPublic/">nuget</a> | 
<a href="https://dev.to/sparky/how-to-test-c-private-methods-sparkytesthelpers-nonpublic-27ab">details</a>
</td></tr>

</table>