SaaSCore.Testing 0.2.0-preview.11

This is a prerelease version of SaaSCore.Testing.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package SaaSCore.Testing --version 0.2.0-preview.11
                    
NuGet\Install-Package SaaSCore.Testing -Version 0.2.0-preview.11
                    
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="SaaSCore.Testing" Version="0.2.0-preview.11" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SaaSCore.Testing" Version="0.2.0-preview.11" />
                    
Directory.Packages.props
<PackageReference Include="SaaSCore.Testing" />
                    
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 SaaSCore.Testing --version 0.2.0-preview.11
                    
#r "nuget: SaaSCore.Testing, 0.2.0-preview.11"
                    
#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 SaaSCore.Testing@0.2.0-preview.11
                    
#: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=SaaSCore.Testing&version=0.2.0-preview.11&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=SaaSCore.Testing&version=0.2.0-preview.11&prerelease
                    
Install as a Cake Tool

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, lightweight TestDbContext for 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 consistent DbContextOptions<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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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