evilbaschdi - EvilBaschdi.Testing 2026.3.27.8-develop
Testing
PM> Install-Package EvilBaschdi.Testing -Version 2026.3.27.8-develop -Source https://www.myget.org/F/evilbaschdi/api/v3/index.json
> nuget.exe install EvilBaschdi.Testing -Version 2026.3.27.8-develop -Source https://www.myget.org/F/evilbaschdi/api/v3/index.json
> dotnet add package EvilBaschdi.Testing --version 2026.3.27.8-develop --source https://www.myget.org/F/evilbaschdi/api/v3/index.json
source https://www.myget.org/F/evilbaschdi/api/v3/index.json
nuget EvilBaschdi.Testing ~> 2026.3.27.8-develop
Copy to clipboard
> choco install EvilBaschdi.Testing --version 2026.3.27.8-develop --source https://www.myget.org/F/evilbaschdi/api/v2
Import-Module PowerShellGet
Register-PSRepository -Name "evilbaschdi" -SourceLocation "https://www.myget.org/F/evilbaschdi/api/v2"
Install-Module -Name "EvilBaschdi.Testing" -RequiredVersion "2026.3.27.8-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
Package Feeds
| Feed Url | |
|---|---|
| https://www.myget.org/F/evilbaschdi/api/v3/index.json | |
| https://codeberg.org/api/packages/evilbaschdi/nuget/index.json |
Build and Codefactor
| main | develop |
|---|---|
Packages
EvilBaschdi.Testing
| main | develop |
|---|---|
| Package Url | |
|---|---|
| https://myget.org/feed/evilbaschdi/package/nuget/evilbaschdi.testing | |
| 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- TheGuardClauseAssertioninstancemethodInfos- Collection of methods to verify
- Throws:
GuardClauseExceptionif 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 singletonAsScoped()- Asserts that the service is registered as scopedAsTransient()- 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)
- FluentAssertions.Microsoft.Extensions.DependencyInjection (>= 1.0.0)
- Microsoft.NET.Test.Sdk (>= 18.3.0)
- Microsoft.Testing.Extensions.CodeCoverage (>= 18.5.2)
- Microsoft.Testing.Extensions.TrxReport (>= 2.1.0)
- 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
Ownersevilbaschdi |
AuthorsSebastian Walter |
Project URLhttps://github.com/evilbaschdi/EvilBaschdi.Testing |
LicenseUnknown |
TagsTesting |
Info1 total downloads |
| 1 downloads for version 2026.3.27.8-develop |
| Download (648.76 KB) |
| Download symbols (13.71 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 |
|