NUnit.Extensions.Helpers 1.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package NUnit.Extensions.Helpers --version 1.1.1                
NuGet\Install-Package NUnit.Extensions.Helpers -Version 1.1.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NUnit.Extensions.Helpers" Version="1.1.1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NUnit.Extensions.Helpers --version 1.1.1                
#r "nuget: NUnit.Extensions.Helpers, 1.1.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NUnit.Extensions.Helpers as a Cake Addin
#addin nuget:?package=NUnit.Extensions.Helpers&version=1.1.1

// Install NUnit.Extensions.Helpers as a Cake Tool
#tool nuget:?package=NUnit.Extensions.Helpers&version=1.1.1                

NUnit.Extensions.Helpers

NuGet License Build Status

Maintainability Rating Reliability Rating Security Rating Bugs Vulnerabilities Coverage

Helpers to generate NUnit tests

This is not an official NUnit package.

Install

Add the NuGet package NUnit.Extensions.Helpers to any project supporting .NET Standard 2.0 or higher.

> dotnet add package NUnit.Extensions.Helpers

Information

Currently the generated source requires Moq and FluentAssertions.

Usage

Constructor parameter null tests

Use the GenerateConstructorParameterNullTests attribute to define the SUT (class which should be tested) to generate constructor parameter tests for.

[GenerateConstructorParameterNullTests(typeof(Document))]
internal partial class DocumentTests
{
    [Test]
    public void Test1()
    {
        Assert.Pass();
    }
}

If the SUT looks like

public class Document
{
    private Stream _stream;
    private IFileTester _fileTester;
    private IOtherFilter _filter;

    public Document(Stream myStream, IFileTester fileTester, IOtherFilter filter)
    {
        _stream = myStream ?? throw new ArgumentNullException(nameof(myStream));
        _fileTester = fileTester ?? throw new ArgumentNullException(nameof(fileTester));
        _filter = filter ?? throw new ArgumentNullException(nameof(filter));
    }
}

following code will be generated:

partial class DocumentTests
{
    [Test]
    public void Throws_Exception_When_MyStream_Is_Null()
    {
        Action action = () => new Document(null, null, null);
        action.Should().Throw<ArgumentNullException>().Which.ParamName.Should().Be("myStream");
    }

    [Test]
    public void Throws_Exception_When_FileTester_Is_Null()
    {
        Action action = () => new Document(Mock.Of<System.IO.Stream>(), null, null);
        action.Should().Throw<ArgumentNullException>().Which.ParamName.Should().Be("fileTester");
    }

    [Test]
    public void Throws_Exception_When_Filter_Is_Null()
    {
        Action action = () => new Document(Mock.Of<System.IO.Stream>(), Mock.Of<Sample.IFileTester>(), null);
        action.Should().Throw<ArgumentNullException>().Which.ParamName.Should().Be("filter");
    }
}

Options

It's possible to generate a nested class with the AsNestedClass argument.

[GenerateConstructorParameterNullTests(typeof(Document), AsNestedClass = true)]
internal partial class TestWithNested
{
}

Web service tests

Use the WebServiceTester helper class. This class reads the OpenApi documentation and can execute arbitary tests.

[Test]
public async Task TestEndpointSecurity()
{
    var tester = new WebServiceTester("swagger.json");

    await tester.VerifySecuredEndpointsRequiresAuthentication(httpClient, CancellationToken.None);
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 116 10/13/2024
1.1.1 106 10/13/2024
1.1.0 114 10/13/2024
1.0.4 120 9/11/2024
1.0.3 130 9/11/2024
1.0.2 111 9/11/2024
1.0.1 111 9/10/2024