SaaSCore.Testing
0.2.0-preview.5
See the version list below for details.
dotnet add package SaaSCore.Testing --version 0.2.0-preview.5
NuGet\Install-Package SaaSCore.Testing -Version 0.2.0-preview.5
<PackageReference Include="SaaSCore.Testing" Version="0.2.0-preview.5" />
<PackageVersion Include="SaaSCore.Testing" Version="0.2.0-preview.5" />
<PackageReference Include="SaaSCore.Testing" />
paket add SaaSCore.Testing --version 0.2.0-preview.5
#r "nuget: SaaSCore.Testing, 0.2.0-preview.5"
#:package SaaSCore.Testing@0.2.0-preview.5
#addin nuget:?package=SaaSCore.Testing&version=0.2.0-preview.5&prerelease
#tool nuget:?package=SaaSCore.Testing&version=0.2.0-preview.5&prerelease
SaaSCore.Testing
SaaSCore.Testing provides a lightweight set of helpers, fixtures, and
utilities to support writing fast, reliable, and repeatable tests across
the SaaSCore ecosystem.
It is designed to remove boilerplate when testing database interactions,
specifications, and application-level components --- while remaining
completely optional and unobtrusive.
This package is used internally by SaaSCore and SaaSCore.* modules
but can also be referenced by consuming applications.
โจ Features
In-memory EF Core test context
Provides a preconfigured, lightweightTestDbContextfor validating repository queries, specifications, and other EF Core logic.Automatic test database bootstrapping
Creates and seeds a fresh database instance per test (or per test class), ensuring test isolation.Specification testing helpers
Fluent helpers for asserting that your specifications generate the correct LINQ expressions and return the expected results.Extension points for custom seeding
Easily inject your own seed data for more complex scenarios.EF Core options factory
A central way to create consistentDbContextOptions<T>across tests without rewriting setup code.
๐ฆ Installation
This package is internal for now. Once extracted into its own NuGet package, it will be installed via:
dotnet add package SaaSCore.Testing
Until then, reference the project from your solution:
<ItemGroup>
<ProjectReference Include="..\SaaSCore.Testing\SaaSCore.Testing.csproj" />
</ItemGroup>
๐ Getting Started
1. Use the built-in TestDbContextFactory
var options = TestDbContextFactory.CreateOptions();
await using var context = new TestDbContext(options);
2. Seed your test data (optional)
context.Seed(users: true, tenants: true);
3. Write your assertions
var results = await context.Users.ToListAsync();
Assert.NotEmpty(results);
๐งช Using Specification Helpers
Example of testing one of your UserSpecifications:
// Arrange
var spec = UserSpecifications.ByExternalId("abc-123");
// Act
var result = await context.ApplySpecification(spec).FirstOrDefaultAsync();
// Assert
Assert.NotNull(result);
Assert.Equal("abc-123", result.ExternalId);
The helpers ensure your specification is applied consistently with the real system.
๐งฐ Included Utilities
Utility Description
TestDbContext A dedicated EF Core DbContext tailored for
tests.
TestDbContextFactory Creates in-memory EF Core options and
context instances.
SeedExtensions Opinionated helpers for injecting stable
test data.
SpecificationTestExtensions Shortcuts for applying and evaluating
specifications.
๐ Design Principles
SaaSCore.Testing follows the core SaaSCore philosophy:
- No mocking what you can prove --- prefer real EF Core behaviour over mocked abstractions.
- Realistic data, minimal ceremony --- seed helpers give structure without forcing test complexity.
- Composable, not prescriptive --- all utilities can be replaced or extended.
๐บ Roadmap
- SQLite-backed test database for higher fidelity integration tests.
- Snapshot testing helpers.
- Additional specification assertion utilities.
| 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 was computed. 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 was computed. 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. |
-
net8.0
- Microsoft.EntityFrameworkCore.InMemory (>= 8.0.22)
- Microsoft.EntityFrameworkCore.Sqlite (>= 8.0.22)
- NSubstitute (>= 5.3.0)
- SaaSCore (>= 0.2.0-preview.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.4.0-preview.1 | 36 | 2/9/2026 |
| 0.3.0-preview.3 | 42 | 1/11/2026 |
| 0.3.0-preview.2 | 45 | 1/5/2026 |
| 0.3.0-preview.1 | 47 | 1/5/2026 |
| 0.2.0-preview.15 | 105 | 12/14/2025 |
| 0.2.0-preview.14 | 98 | 12/14/2025 |
| 0.2.0-preview.13 | 95 | 12/14/2025 |
| 0.2.0-preview.12 | 71 | 12/12/2025 |
| 0.2.0-preview.11 | 168 | 12/11/2025 |
| 0.2.0-preview.10 | 362 | 12/11/2025 |
| 0.2.0-preview.9 | 363 | 12/11/2025 |
| 0.2.0-preview.8 | 363 | 12/11/2025 |
| 0.2.0-preview.7 | 363 | 12/11/2025 |
| 0.2.0-preview.6 | 355 | 12/11/2025 |
| 0.2.0-preview.5 | 363 | 12/11/2025 |
| 0.2.0-preview.4 | 365 | 12/11/2025 |
| 0.2.0-preview.3 | 368 | 12/11/2025 |
| 0.2.0-preview.2 | 380 | 12/10/2025 |
| 0.2.0-preview.1 | 384 | 12/10/2025 |