CoreEx.UnitTesting
4.0.0-preview-1
dotnet add package CoreEx.UnitTesting --version 4.0.0-preview-1
NuGet\Install-Package CoreEx.UnitTesting -Version 4.0.0-preview-1
<PackageReference Include="CoreEx.UnitTesting" Version="4.0.0-preview-1" />
<PackageVersion Include="CoreEx.UnitTesting" Version="4.0.0-preview-1" />
<PackageReference Include="CoreEx.UnitTesting" />
paket add CoreEx.UnitTesting --version 4.0.0-preview-1
#r "nuget: CoreEx.UnitTesting, 4.0.0-preview-1"
#:package CoreEx.UnitTesting@4.0.0-preview-1
#addin nuget:?package=CoreEx.UnitTesting&version=4.0.0-preview-1&prerelease
#tool nuget:?package=CoreEx.UnitTesting&version=4.0.0-preview-1&prerelease
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,
ValidationExceptionerror mapping) are applied consistently across all test frameworks (NUnit, xUnit, MSTest) without manual wiring. EventPublisherDecoratorallows event expectations to be declared and asserted against the real outbox/publisher pipeline without requiring live infrastructure.JsonDataReaderenables 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:
UnitTestExOneOffTestSetUpregisters CoreEx JSON defaults, the environment user, andValidationExceptionerror assertion handling with UnitTestEx on first assembly load. - โ
Fluent value expectations:
UnitTestExExpectationsstatic class extendsIValueExpectations<TValue, TSelf>andIExpectations<TSelf>withExpectIdentifier,ExpectETag,ExpectChangeLogCreated,ExpectChangeLogUpdated, andIgnorePathsto assert domain-entity lifecycle concerns. - ๐ฌ Event-capture and assertion:
UseExpectedEventPublisherreplaces the real publisher withEventPublisherDecoratorat test-host setup time;ExpectEvents/ExpectNoEventsplus publisher-specific overloads (ExpectSqlServerOutboxEvents,ExpectPostgresOutboxEvents,ExpectAzureServiceBusEvents) declare and then verify published events asCloudEventJSON comparisons. - โก Publisher-specific outbox helpers: dedicated
ExpectSqlServerOutboxEvents,ExpectNoSqlServerOutboxEvents,ExpectPostgresOutboxEvents,ExpectNoPostgresOutboxEvents,ExpectAzureServiceBusEvents, andExpectNoAzureServiceBusEventsextension methods target each outbox/publisher by its registered service key. - ๐ง Broad extension surface:
UnitTestExExtensionsaddsScoped/ExecutionContextscoping helpers,CreateCloudEventFromevent builders,AssertProblemDetailsTitleHTTP response assertions,ClearFusionCacheAsynccache reset, and validator-levelAssertSuccess/AssertErrorsshortcuts directly onTesterBaseandIValidator<T>. - ๐ Validation shortcuts:
AssertSuccessandAssertErrorsextension methods execute aCoreEx.Validation.IValidator<T>and assert the outcome inline, using AwesomeAssertions for readable failure messages. - ๐ FusionCache test reset:
ClearFusionCacheAsyncclears the registeredIFusionCachebetween test runs to prevent state bleed in cached reference-data or other cache-backed scenarios. - ๐ JSON/YAML seed-data loading:
JsonDataReaderparses JSON or YAML into aJsonNodetree and deep-copies it with^tokenand(^token)placeholder substitution, returning a fully resolvedJsonNode(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 onJsonDataReaderOptions.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 |
Related namespaces
CoreEx- ProvidesExecutionContext,ValidationException,EventData, andJsonDefaultswired in byUnitTestExOneOffTestSetUp.CoreEx.Events- DefinesIEventPublisherandEventDatathatEventPublisherDecoratorwraps for event capture.CoreEx.Azure.Messaging.ServiceBus-ServiceBusPublisherwhose service key is targeted byExpectAzureServiceBusEvents.CoreEx.Database.SqlServer-SqlServerOutboxPublisherwhose service key is targeted byExpectSqlServerOutboxEvents;JsonDataReaderseeds SQL Server test databases.CoreEx.Database.Postgres-PostgresOutboxPublisherwhose service key is targeted byExpectPostgresOutboxEvents;JsonDataReaderseeds PostgreSQL test databases.CoreEx.Caching.FusionCache-IFusionCacheimplementation cleared byClearFusionCacheAsync.CoreEx.Validation-IValidator<T>andValidationExceptiontargeted by theAssertSuccess/AssertErrorsand one-off setup extensions.
Additional Resources
- UnitTestEx - The underlying test-host framework that
CoreEx.UnitTestingextends; providesTesterBase,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.yamlseed files before they are handed toJsonDataReader.
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 | Versions 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. |
-
net10.0
- AwesomeAssertions (>= 9.4.0)
- CoreEx (>= 4.0.0-preview-1)
- CoreEx.Azure.Messaging.ServiceBus (>= 4.0.0-preview-1)
- CoreEx.Caching.FusionCache (>= 4.0.0-preview-1)
- CoreEx.Database.Postgres (>= 4.0.0-preview-1)
- CoreEx.Database.SqlServer (>= 4.0.0-preview-1)
- CoreEx.Events (>= 4.0.0-preview-1)
- DbEx.Postgres (>= 3.1.2)
- DbEx.SqlServer (>= 3.1.2)
- UnitTestEx (>= 5.11.0)
- YamlDotNet (>= 18.0.0)
-
net8.0
- AwesomeAssertions (>= 9.4.0)
- CoreEx (>= 4.0.0-preview-1)
- CoreEx.Azure.Messaging.ServiceBus (>= 4.0.0-preview-1)
- CoreEx.Caching.FusionCache (>= 4.0.0-preview-1)
- CoreEx.Database.Postgres (>= 4.0.0-preview-1)
- CoreEx.Database.SqlServer (>= 4.0.0-preview-1)
- CoreEx.Events (>= 4.0.0-preview-1)
- DbEx.Postgres (>= 3.1.2)
- DbEx.SqlServer (>= 3.1.2)
- UnitTestEx (>= 5.11.0)
- YamlDotNet (>= 18.0.0)
-
net9.0
- AwesomeAssertions (>= 9.4.0)
- CoreEx (>= 4.0.0-preview-1)
- CoreEx.Azure.Messaging.ServiceBus (>= 4.0.0-preview-1)
- CoreEx.Caching.FusionCache (>= 4.0.0-preview-1)
- CoreEx.Database.Postgres (>= 4.0.0-preview-1)
- CoreEx.Database.SqlServer (>= 4.0.0-preview-1)
- CoreEx.Events (>= 4.0.0-preview-1)
- DbEx.Postgres (>= 3.1.2)
- DbEx.SqlServer (>= 3.1.2)
- UnitTestEx (>= 5.11.0)
- YamlDotNet (>= 18.0.0)
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 |