CoreEx.UnitTesting
4.0.0
dotnet add package CoreEx.UnitTesting --version 4.0.0
NuGet\Install-Package CoreEx.UnitTesting -Version 4.0.0
<PackageReference Include="CoreEx.UnitTesting" Version="4.0.0" />
<PackageVersion Include="CoreEx.UnitTesting" Version="4.0.0" />
<PackageReference Include="CoreEx.UnitTesting" />
paket add CoreEx.UnitTesting --version 4.0.0
#r "nuget: CoreEx.UnitTesting, 4.0.0"
#:package CoreEx.UnitTesting@4.0.0
#addin nuget:?package=CoreEx.UnitTesting&version=4.0.0
#tool nuget:?package=CoreEx.UnitTesting&version=4.0.0
CoreEx.UnitTesting
Provides the complete CoreEx unit- and integration-testing toolkit: fluent expectations, event-capture assertions, 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.
CoreEx.Data.Json's JsonDataReader — a JSON-to-JsonNode bridge that supports parameterised ^token-style substitutions for generated values (ids, timestamps, tenant/user context) and multiple naming conventions — is a transitive dependency (via CoreEx.Data), not owned by this package. It makes it straightforward to seed SQL Server, PostgreSQL, or Cosmos DB 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.
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,AssertProblemDetailsHTTP 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.
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, AssertProblemDetails, ClearFusionCacheAsync, UseExpectedEventPublisher, AssertSuccess, and AssertErrors. |
Namespaces
| Namespace | Description | Documentation |
|---|---|---|
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.Data-JsonDataReader(in theCoreEx.Data.Jsonnamespace) — a transitive dependency, not owned by this package — parses JSON/YAML with^tokenplaceholder substitution to seed SQL Server, PostgreSQL, or Cosmos DB test databases directly fromdata.yaml/JSON resource files.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.CoreEx.Database.Postgres-PostgresOutboxPublisherwhose service key is targeted byExpectPostgresOutboxEvents.CoreEx.Cosmos-CosmosDbBatch/CosmosDbContainerExtensions(in theCoreEx.Cosmos.Extendednamespace) — a transitive dependency, not owned by this package — provision/reset a Cosmos DB container and import raw JSON for test seeding.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.
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.6.0)
- CoreEx (>= 4.0.0)
- CoreEx.Azure.Messaging.ServiceBus (>= 4.0.0)
- CoreEx.Caching.FusionCache (>= 4.0.0)
- CoreEx.Cosmos (>= 4.0.0)
- CoreEx.Data (>= 4.0.0)
- CoreEx.Database.Postgres (>= 4.0.0)
- CoreEx.Database.SqlServer (>= 4.0.0)
- CoreEx.Events (>= 4.0.0)
- DbEx.Postgres (>= 3.2.0)
- DbEx.SqlServer (>= 3.2.0)
- UnitTestEx (>= 5.11.1)
-
net8.0
- AwesomeAssertions (>= 9.6.0)
- CoreEx (>= 4.0.0)
- CoreEx.Azure.Messaging.ServiceBus (>= 4.0.0)
- CoreEx.Caching.FusionCache (>= 4.0.0)
- CoreEx.Cosmos (>= 4.0.0)
- CoreEx.Data (>= 4.0.0)
- CoreEx.Database.Postgres (>= 4.0.0)
- CoreEx.Database.SqlServer (>= 4.0.0)
- CoreEx.Events (>= 4.0.0)
- DbEx.Postgres (>= 3.2.0)
- DbEx.SqlServer (>= 3.2.0)
- UnitTestEx (>= 5.11.1)
-
net9.0
- AwesomeAssertions (>= 9.6.0)
- CoreEx (>= 4.0.0)
- CoreEx.Azure.Messaging.ServiceBus (>= 4.0.0)
- CoreEx.Caching.FusionCache (>= 4.0.0)
- CoreEx.Cosmos (>= 4.0.0)
- CoreEx.Data (>= 4.0.0)
- CoreEx.Database.Postgres (>= 4.0.0)
- CoreEx.Database.SqlServer (>= 4.0.0)
- CoreEx.Events (>= 4.0.0)
- DbEx.Postgres (>= 3.2.0)
- DbEx.SqlServer (>= 3.2.0)
- UnitTestEx (>= 5.11.1)
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 | 29 | 9/21/2026 |
| 4.0.0-preview-5 | 112 | 8/23/2026 |
| 4.0.0-preview-4 | 100 | 8/21/2026 |
| 4.0.0-preview-3 | 137 | 8/4/2026 |
| 4.0.0-preview-2 | 115 | 7/10/2026 |
| 4.0.0-preview-1 | 135 | 6/20/2026 |
| 3.31.0 | 6,273 | 2/1/2025 |
| 3.30.2 | 321 | 12/11/2024 |
| 3.30.1 | 331 | 12/9/2024 |
| 3.30.0 | 4,941 | 11/21/2024 |
| 3.29.0 | 1,911 | 11/19/2024 |
| 3.28.0 | 307 | 11/9/2024 |
| 3.27.3 | 403 | 10/23/2024 |
| 3.27.2 | 330 | 10/17/2024 |
| 3.27.1 | 404 | 10/15/2024 |
| 3.27.0 | 347 | 10/11/2024 |
| 3.26.0 | 283 | 10/3/2024 |
| 3.25.6 | 402 | 10/2/2024 |
| 3.25.5 | 365 | 9/25/2024 |
| 3.25.4 | 377 | 9/24/2024 |