evilbaschdi - EvilBaschdi.Testing 2026.5.12.19-develop

Testing

PM> Install-Package EvilBaschdi.Testing -Version 2026.5.12.19-develop -Source https://www.myget.org/F/evilbaschdi/api/v3/index.json

Copy to clipboard

> nuget.exe install EvilBaschdi.Testing -Version 2026.5.12.19-develop -Source https://www.myget.org/F/evilbaschdi/api/v3/index.json

Copy to clipboard

> dotnet add package EvilBaschdi.Testing --version 2026.5.12.19-develop --source https://www.myget.org/F/evilbaschdi/api/v3/index.json

Copy to clipboard
<PackageReference Include="EvilBaschdi.Testing" Version="2026.5.12.19-develop" />
Copy to clipboard
source https://www.myget.org/F/evilbaschdi/api/v3/index.json

nuget EvilBaschdi.Testing  ~> 2026.5.12.19-develop
Copy to clipboard

> choco install EvilBaschdi.Testing --version 2026.5.12.19-develop --source https://www.myget.org/F/evilbaschdi/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "evilbaschdi" -SourceLocation "https://www.myget.org/F/evilbaschdi/api/v2"
Install-Module -Name "EvilBaschdi.Testing" -RequiredVersion "2026.5.12.19-develop" -Repository "evilbaschdi" -AllowPreRelease
Copy to clipboard

Browse the sources in this package using Visual Studio or WinDbg by configuring the following symbol server URL: https://www.myget.org/F/evilbaschdi/api/v2/symbolpackage/


EvilBaschdi.Testing

Source Code of EvilBaschdi.Testing

License: MIT

Package Feeds

Feed Url
myget.org https://www.myget.org/F/evilbaschdi/api/v3/index.json
codeberg.org https://codeberg.org/api/packages/evilbaschdi/nuget/index.json

Build and Codefactor

main develop
evilbaschdi Azure DevOps Build Status evilbaschdi Azure DevOps Build Status
CodeFactor CodeFactor

Packages

EvilBaschdi.Testing

main develop
MyGet Version MyGet Version
Package Url
myget.org https://myget.org/feed/evilbaschdi/package/nuget/evilbaschdi.testing
codeberg.org https://codeberg.org/evilbaschdi/-/packages/nuget/evilbaschdi.testing

Installation

PM> Install-Package EvilBaschdi.Testing

Features

This library provides a comprehensive set of testing utilities and assertion extensions:

  • Guard Clause Assertions - Verify null guards on async methods
  • Fluent Assertions for Microsoft.Extensions.DependencyInjection - Assert service configurations
  • FluentAssertions Extensions - Enhanced testing for dependency injection

AutoFixture Attributes

NSubstituteOmitAutoPropertiesTrueAutoDataAttribute

A custom xUnit [Theory] attribute that combines AutoFixture's AutoDataAttribute with NSubstitute automatic mocking and sets OmitAutoProperties = true. This means the fixture will create mocks but will not automatically populate properties—you must explicitly configure them.

using EvilBaschdi.Testing;
using Xunit;

[Theory, NSubstituteOmitAutoPropertiesTrueAutoData]
public void MyTest(IMyService service, MyDependency dependency)
{
    // service and dependency are automatically created and injected
    // properties are not auto-populated - configure them as needed
}

NSubstituteOmitAutoPropertiesTrueInlineAutoDataAttribute

Combines InlineAutoDataAttribute with NSubstitute automatic mocking and OmitAutoProperties = true. Allows you to provide inline data values alongside auto-generated dependencies.

using EvilBaschdi.Testing;
using Xunit;

[Theory]
[NSubstituteOmitAutoPropertiesTrueInlineAutoData("value1", 42)]
public void MyTest(string inlineValue, int inlineNumber, IMyService service)
{
    // inlineValue and inlineNumber come from the attribute parameters
    // service is automatically created by the fixture
}

Guard Clause Assertions

Overview

GuardClauseAssertionExtensions provides extension methods for verifying that all public asynchronous methods on a specified type have appropriate null guards for their reference type parameters.

using EvilBaschdi.Testing.Extensions;
using AutoFixture.Xunit3;

[Theory, NSubstituteOmitAutoPropertiesTrueAutoData]
public void VerifyAllAsyncMethodsHaveNullGuards(GuardClauseAssertion assertion)
{
    assertion.VerifyTask<MyAsyncService>(
        typeof(MyAsyncService).GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance));
}

VerifyTask

Verifies that all public async methods on type T have null guards for their reference type parameters.

var assertion = new GuardClauseAssertion(new Fixture());
assertion.VerifyTask<MyService>(methodInfos);
  • Parameters:
    • assertion - The GuardClauseAssertion instance
    • methodInfos - Collection of methods to verify
  • Throws: GuardClauseException if a method doesn't have proper null guards
  • Note: Value types and non-reference parameters are automatically skipped

Fluent Assertions for Microsoft.Extensions.DependencyInjection

This library contains fluent assertion extensions for testing Microsoft.Extensions.DependencyInjection service configurations.

Note: This library is based on FluentAssertions.Microsoft.Extensions.DependencyInjection by zachdean.

Quick Start

using EvilBaschdi.Testing;
using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();
services.AddSingleton<ISomeService, SomeService>();
services.AddTransient<ITransient, Transient>();
services.AddScoped<IScoped, Scoped>();

// Assert that a service is registered with the correct implementation and lifetime
services.Should()
    .HaveService<ISomeService>()
    .WithImplementation<SomeService>()
    .AsSingleton();

API Reference

HaveCount(int expected)

Asserts that the service collection contains the expected number of service registrations.

services.Should().HaveCount(5);

HaveService<TService>()

Asserts that a service of type TService is registered in the service collection.

services.Should().HaveService<ISomeService>();

WithCount(int expected)

Asserts that the service is registered a specific number of times. Can be chained before lifetime assertions.

services.Should()
    .HaveService<ISomeService>()
    .WithCount(2);

WithImplementation<TImplementation>()

Asserts that the service is registered with a specific implementation type. Can be chained for multiple implementations.

services.Should()
    .HaveService<ISomeService>()
    .WithImplementation<SomeService>();

WithFactory()

Asserts that the service is registered with a factory function (e.g., via AddSingleton(provider => ...), AddScoped(provider => ...), AddTransient(provider => ...)).

services.Should()
    .HaveService<ISomeService>()
    .WithFactory();

WithFactory(Func<IServiceProvider, TService> expectedFactory)

Asserts that the service is registered with a specific factory function.

services.Should()
    .HaveService<ISomeService>()
    .WithFactory(provider => new SomeService());

Lifetime Assertions

  • AsSingleton() - Asserts that the service is registered as a singleton
  • AsScoped() - Asserts that the service is registered as scoped
  • AsTransient() - Asserts that the service is registered as transient
services.Should()
    .HaveService<ISomeService>()
    .AsSingleton();

services.Should()
    .HaveService<IRepository>()
    .AsTransient();

services.Should()
    .HaveService<IUnitOfWork>()
    .AsScoped();

Method Chaining with And()

Chain multiple assertions together:

services.Should()
    .HaveService<ISomeService>()
    .AsSingleton()
    .And()
    .HaveCount(3);
  • .NETFramework 10.0
    • AutoFixture.AutoNSubstitute (>= 4.18.1)
    • AutoFixture.Idioms (>= 4.18.1)
    • AutoFixture.Xunit3 (>= 4.19.0)
    • FluentAssertions (>= 7.2.2 && < 8.0.0)
    • Microsoft.Extensions.DependencyInjection (>= 10.0.8)
    • Microsoft.NET.Test.Sdk (>= 18.5.1)
    • Microsoft.Testing.Extensions.CodeCoverage (>= 18.6.2)
    • Microsoft.Testing.Extensions.TrxReport (>= 2.2.2)
    • NCrunch.Framework (>= 5.11.0)
    • NSubstitute (>= 6.0.0-rc.1)
    • xunit.v3.extensibility.core (>= 3.2.2)
    • xunit.v3.mtp-v2 (>= 3.2.2)
    • xunit.v3.runner.utility (>= 3.2.2)
  • .NETFramework 10.0: 10.0.0.0

Owners

evilbaschdi

Authors

Sebastian Walter

Project URL

https://github.com/evilbaschdi/EvilBaschdi.Testing

License

Unknown

Tags

Testing

Info

1 total downloads
0 downloads for version 2026.5.12.19-develop
Download (653.16 KB)
Download symbols (14.77 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
2026.5.12.19 653.15 KB Tue, 12 May 2026 19:14:18 GMT 0
2026.5.12.19-develop 653.16 KB Tue, 12 May 2026 19:13:36 GMT 0
2026.4.28.17 653.14 KB Tue, 28 Apr 2026 17:26:25 GMT 0
2026.4.28.17-develop 653.16 KB Tue, 28 Apr 2026 17:22:44 GMT 0
2026.4.6.14-develop 652.47 KB Mon, 06 Apr 2026 14:18:08 GMT 0
2026.4.6.13-develop 652.28 KB Mon, 06 Apr 2026 13:42:51 GMT 0
2026.3.27.8-develop 648.76 KB Fri, 27 Mar 2026 08:54:23 GMT 1