NUnit

A batteries-included meta-package for testing Dosaic-based services. Instead of tracking down individual testing dependencies for every project, add this single package and get a complete, pre-configured testing setup.

Installation

dotnet add package Dosaic.Testing.NUnit

Included Packages

Package
Version
Purpose

NUnit

4.5.0

Test framework

Allure.NUnit

2.14.1

Test reporting and attachments

AwesomeAssertions

9.4.0

Fluent assertion library (.Should())

NSubstitute

5.3.0

Mocking framework

NSubstitute.Analyzers.CSharp

1.0.17

Static analysis for correct NSubstitute usage (analyzer only)

Bogus

35.6.5

Fake data generation

NaughtyStrings.Bogus

3.0.0

Naughty/edge-case strings provider for Bogus

OpenTelemetry

1.15.0

Distributed tracing and metrics primitives

Microsoft.EntityFrameworkCore

EF Core (required for EF assertion helpers)

Microsoft.EntityFrameworkCore.Relational

EF Core relational (required for migration assertions)

Chronos.Net

2.0.24

Date/time provider abstractions

TngTech.ArchUnitNET.NUnit

0.13.2

Architecture unit tests

The package also carries transitive project references to Dosaic.Hosting.Abstractions (core plugin interfaces) and Dosaic.DevTools.Seeding (EF Core fake data seeder).

Test Helpers

Type
Namespace
Description

FakeLogger<T>

Dosaic.Testing.NUnit.Assertions

In-memory ILogger<T> that captures log entries for assertion

TestMetricsCollector

Dosaic.Testing.NUnit

Listens to a named System.Diagnostics.Metrics instrument and collects measurements

TestMetricsCollectorAssertions

Dosaic.Testing.NUnit

Fluent assertion extensions for List<MetricMeasurement>

ActivityTestBootstrapper

Dosaic.Testing.NUnit

Registers a global ActivityListener so Activity instances are sampled in tests

TestingDefaults

Dosaic.Testing.NUnit

Creates a pre-configured ServiceCollection / ServiceProvider with logging, date-time providers, and GlobalStatusCodeOptions

CustomConfiguration

Dosaic.Testing.NUnit

Fluent builder for in-memory IConfiguration instances

BaseTestEntity / BaseSubTestEntity

Dosaic.Testing.NUnit.Models

Reusable record types for tests that need a simple entity graph

PluginServiceConfigurationAssertions

Dosaic.Testing.NUnit.Assertions

Asserts that an IPluginServiceConfiguration registers expected services

PluginEndpointConfigurationAssertions

Dosaic.Testing.NUnit.Assertions

Asserts that an IPluginEndpointsConfiguration registers expected routes and HTTP methods

EntityTypeAssertions / DbContextAssertions

Dosaic.Testing.NUnit.Assertions

Fluent assertions for EF Core entity type mappings, migrations, indexes, foreign keys, and seed data

TracingAssertions

Dosaic.Testing.NUnit.Assertions

Asserts that a TracerProvider has registered expected activity sources and instrumentations

ArgExt

Dosaic.Testing.NUnit.Extensions

NSubstitute argument matcher that delegates matching to an AwesomeAssertions assertion action

ArchitectureExtensions

Dosaic.Testing.NUnit.Extensions

Helpers for loading Architecture instances from the current or specific assemblies (ArchUnitNET)

ObjectExtensions

Dosaic.Testing.NUnit.Extensions

Reflection helper to read private/internal fields or properties by name

Usage

FakeLogger<T>

Capture and assert on log entries without a real logging infrastructure.

TestMetricsCollector

Listen to a named System.Diagnostics.Metrics instrument and verify emitted measurements.

ActivityTestBootstrapper

Enable Activity recording in tests (call once, e.g. in [OneTimeSetUp]).

TestingDefaults

Get a pre-wired ServiceCollection or ServiceProvider including logging and Chronos date-time providers.

CustomConfiguration

Build an IConfiguration from key/value pairs without touching the file system.

PluginServiceConfigurationAssertions

Verify that a plugin registers the expected services into the DI container.

PluginEndpointConfigurationAssertions

Verify that a plugin registers the expected routes and HTTP methods.

EF Core Assertions (EntityTypeAssertions / DbContextAssertions)

Assert EF Core entity mappings, migration state, and seed data.

TracingAssertions

Verify that a TracerProvider (built during plugin configuration) has registered the correct sources and instrumentations.

ArgExt (NSubstitute argument matching with AwesomeAssertions)

Use fluent assertion lambdas as NSubstitute argument matchers.

ArchitectureExtensions

Load an Architecture from the calling assembly or a set of specific assemblies for use with ArchUnitNET.

ObjectExtensions

Read private or internal fields and properties by name via reflection (useful when testing internal state without exposing it).

Last updated