CoreEx.UnitTesting 4.0.0-preview-1

This is a prerelease version of CoreEx.UnitTesting.
dotnet add package CoreEx.UnitTesting --version 4.0.0-preview-1
                    
NuGet\Install-Package CoreEx.UnitTesting -Version 4.0.0-preview-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="CoreEx.UnitTesting" Version="4.0.0-preview-1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CoreEx.UnitTesting" Version="4.0.0-preview-1" />
                    
Directory.Packages.props
<PackageReference Include="CoreEx.UnitTesting" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CoreEx.UnitTesting --version 4.0.0-preview-1
                    
#r "nuget: CoreEx.UnitTesting, 4.0.0-preview-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.
#:package CoreEx.UnitTesting@4.0.0-preview-1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CoreEx.UnitTesting&version=4.0.0-preview-1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CoreEx.UnitTesting&version=4.0.0-preview-1&prerelease
                    
Install as a Cake Tool

CoreEx.UnitTesting

Provides the complete CoreEx unit- and integration-testing toolkit: fluent expectations, event-capture assertions, JSON seed-data loading, and convenience extensions that bridge UnitTestEx with every major CoreEx subsystem.

Overview

CoreEx.UnitTesting is the single testing package that covers the entire CoreEx ecosystem. Rather than shipping a separate CoreEx.UnitTesting.Events, CoreEx.UnitTesting.SqlServer, or similar per-feature test packages, all capabilities are consolidated here deliberately. Unit- and integration-testing packages are never deployed to production, so the additional transitive references carry no runtime cost; consolidating into one package eliminates version-alignment friction, reduces <PackageReference> noise in test projects, and makes the full test surface immediately discoverable.

The package extends UnitTestEx โ€” the CoreEx-recommended test host โ€” with CoreEx-specific registration helpers, expectations, and assertion extensions. These operate by injecting an EventPublisherDecorator into the DI container so published events are captured during a test run and then asserted after the fact, without touching the real publisher. The one-off setup hook (UnitTestExOneOffTestSetUp) wires CoreEx defaults (JsonDefaults, AuthenticationUser, ValidationException error matching) into the UnitTestEx infrastructure automatically when the assembly is loaded.

A companion Data child namespace provides JsonDataReader โ€” a JSON-to-JsonNode bridge that supports parameterised {{token}}-style substitutions for generated values (ids, timestamps, tenant/user context) and multiple naming conventions. This makes it straightforward to seed SQL Server or PostgreSQL test databases directly from data.yaml or JSON resource files.

Motivation

  • A single package covers all CoreEx test concerns; test projects need only one <PackageReference> to access every helper regardless of which CoreEx features the service under test uses.
  • Keeping test support consolidated maximises discoverability: developers find assertions for events, reference data, outbox patterns, caching, validation, and HTTP all in one place rather than hunting across multiple packages.
  • Automatic one-off set-up ensures CoreEx defaults (serialization, user context, ValidationException error mapping) are applied consistently across all test frameworks (NUnit, xUnit, MSTest) without manual wiring.
  • EventPublisherDecorator allows event expectations to be declared and asserted against the real outbox/publisher pipeline without requiring live infrastructure.
  • JsonDataReader enables repeatable, parameterised seed data from JSON/YAML resources rather than hard-coded insert statements.

Key capabilities

  • ๐Ÿงช Unified test package: one <PackageReference> covers testing support for all CoreEx subsystems โ€” events, outbox (SQL Server and PostgreSQL), Azure Service Bus, caching (FusionCache), validation, HTTP, ETag, identifier, and change-log assertions.
  • ๐Ÿ“ฆ Automatic CoreEx wiring: UnitTestExOneOffTestSetUp registers CoreEx JSON defaults, the environment user, and ValidationException error assertion handling with UnitTestEx on first assembly load.
  • โœ… Fluent value expectations: UnitTestExExpectations static class extends IValueExpectations<TValue, TSelf> and IExpectations<TSelf> with ExpectIdentifier, ExpectETag, ExpectChangeLogCreated, ExpectChangeLogUpdated, and IgnorePaths to assert domain-entity lifecycle concerns.
  • ๐Ÿ’ฌ Event-capture and assertion: UseExpectedEventPublisher replaces the real publisher with EventPublisherDecorator at test-host setup time; ExpectEvents/ExpectNoEvents plus publisher-specific overloads (ExpectSqlServerOutboxEvents, ExpectPostgresOutboxEvents, ExpectAzureServiceBusEvents) declare and then verify published events as CloudEvent JSON comparisons.
  • โšก Publisher-specific outbox helpers: dedicated ExpectSqlServerOutboxEvents, ExpectNoSqlServerOutboxEvents, ExpectPostgresOutboxEvents, ExpectNoPostgresOutboxEvents, ExpectAzureServiceBusEvents, and ExpectNoAzureServiceBusEvents extension methods target each outbox/publisher by its registered service key.
  • ๐Ÿ”ง Broad extension surface: UnitTestExExtensions adds Scoped/ExecutionContext scoping helpers, CreateCloudEventFrom event builders, AssertProblemDetailsTitle HTTP response assertions, ClearFusionCacheAsync cache reset, and validator-level AssertSuccess/AssertErrors shortcuts directly on TesterBase and IValidator<T>.
  • ๐Ÿ“ Validation shortcuts: AssertSuccess and AssertErrors extension methods execute a CoreEx.Validation.IValidator<T> and assert the outcome inline, using AwesomeAssertions for readable failure messages.
  • ๐Ÿ”„ FusionCache test reset: ClearFusionCacheAsync clears the registered IFusionCache between test runs to prevent state bleed in cached reference-data or other cache-backed scenarios.
  • ๐Ÿ“Š JSON/YAML seed-data loading: JsonDataReader parses JSON or YAML into a JsonNode tree and deep-copies it with ^token and (^token) placeholder substitution, returning a fully resolved JsonNode (or directly deserialised value) ready to seed a test database or drive request bodies. Built-in tokens cover ^id, ^now, ^tenant_id, ^user_name, and more; custom tokens are registered on JsonDataReaderOptions.Parameters.

Key types

Type Description
UnitTestExOneOffTestSetUp Internal one-off UnitTestEx initializer; configures CoreEx JSON serialization defaults, the environment user name, and ValidationException error-assertion integration automatically on assembly load.
UnitTestExExpectations Static partial class; aggregates all CoreEx-specific value and tester expectation extension methods: ExpectIdentifier, ExpectETag, ExpectChangeLogCreated, ExpectChangeLogUpdated, IgnorePaths, and the full event and outbox expectation surface.
UnitTestExExtensions Static partial class; aggregates all CoreEx-specific TesterBase and IValidator<T> extension methods: Scoped, CreateCloudEventFrom, AssertProblemDetailsTitle, ClearFusionCacheAsync, UseExpectedEventPublisher, AssertSuccess, and AssertErrors.

Namespaces

Namespace Description Documentation
CoreEx.UnitTesting.Data JsonDataReader โ€” a hierarchical mutating reader that parses JSON or YAML and deep-copies the JsonNode tree with ^token placeholder substitution; consumers use the resolved node (or Deserialize<T>) to seed databases or build request payloads. ๐Ÿ“– README
CoreEx.UnitTesting.Events EventExpectationsConfig, EventExpectationAssertor, EventExpectations, and EventPublisherDecorator; the infrastructure for capturing and asserting published events in tests. ๐Ÿ“– README
  • CoreEx - Provides ExecutionContext, ValidationException, EventData, and JsonDefaults wired in by UnitTestExOneOffTestSetUp.
  • CoreEx.Events - Defines IEventPublisher and EventData that EventPublisherDecorator wraps for event capture.
  • CoreEx.Azure.Messaging.ServiceBus - ServiceBusPublisher whose service key is targeted by ExpectAzureServiceBusEvents.
  • CoreEx.Database.SqlServer - SqlServerOutboxPublisher whose service key is targeted by ExpectSqlServerOutboxEvents; JsonDataReader seeds SQL Server test databases.
  • CoreEx.Database.Postgres - PostgresOutboxPublisher whose service key is targeted by ExpectPostgresOutboxEvents; JsonDataReader seeds PostgreSQL test databases.
  • CoreEx.Caching.FusionCache - IFusionCache implementation cleared by ClearFusionCacheAsync.
  • CoreEx.Validation - IValidator<T> and ValidationException targeted by the AssertSuccess/AssertErrors and one-off setup extensions.

Additional Resources

  • UnitTestEx - The underlying test-host framework that CoreEx.UnitTesting extends; provides TesterBase, ApiTester, GenericTester, IExpectations, and the framework-agnostic assertion infrastructure.
  • AwesomeAssertions - Fluent assertion library used by the validation shortcuts and internal assertion helpers.
  • YamlDotNet - Used internally to parse data.yaml seed files before they are handed to JsonDataReader.

AI Usage Guide

An AGENTS.md file is included with this package. AI coding assistants (GitHub Copilot, Claude, Cursor, etc.) that support workspace-injected package documentation will automatically surface concise usage guidance, code examples, and Do Not rules for this package without requiring a local CoreEx checkout.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on CoreEx.UnitTesting:

Package Downloads
Beef.Test.NUnit

Business Entity Execution Framework (Beef) NUnit extensions for testing (Beef v4.x backwards compatibility only).

CoreEx.UnitTesting.NUnit

CoreEx NUnit UnitTesting (UnitTestEx) extras.

CoreEx.UnitTesting.Azure.Functions

CoreEx UnitTesting (UnitTestEx) extras.

CoreEx.UnitTesting.Azure.ServiceBus

CoreEx UnitTesting (UnitTestEx) extras.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on CoreEx.UnitTesting:

Repository Stars
Avanade/Beef
The Business Entity Execution Framework (Beef) framework, and the underlying code generation, has been primarily created to support the industrialization of API development.
Version Downloads Last Updated
4.0.0-preview-1 40 6/20/2026
3.31.0 5,300 2/1/2025
3.30.2 303 12/11/2024
3.30.1 309 12/9/2024
3.30.0 3,929 11/21/2024
3.29.0 1,617 11/19/2024
3.28.0 281 11/9/2024
3.27.3 369 10/23/2024
3.27.2 313 10/17/2024
3.27.1 377 10/15/2024
3.27.0 320 10/11/2024
3.26.0 256 10/3/2024
3.25.6 372 10/2/2024
3.25.5 338 9/25/2024
3.25.4 339 9/24/2024
3.25.3 323 9/18/2024
3.25.2 309 9/17/2024
3.25.1 340 9/16/2024
3.25.0 304 9/10/2024
3.24.1 376 8/7/2024
Loading failed