Alvecta.Foundation.Application.Ports.Testing
8.0.77
See the version list below for details.
dotnet add package Alvecta.Foundation.Application.Ports.Testing --version 8.0.77
NuGet\Install-Package Alvecta.Foundation.Application.Ports.Testing -Version 8.0.77
<PackageReference Include="Alvecta.Foundation.Application.Ports.Testing" Version="8.0.77" />
<PackageVersion Include="Alvecta.Foundation.Application.Ports.Testing" Version="8.0.77" />
<PackageReference Include="Alvecta.Foundation.Application.Ports.Testing" />
paket add Alvecta.Foundation.Application.Ports.Testing --version 8.0.77
#r "nuget: Alvecta.Foundation.Application.Ports.Testing, 8.0.77"
#:package Alvecta.Foundation.Application.Ports.Testing@8.0.77
#addin nuget:?package=Alvecta.Foundation.Application.Ports.Testing&version=8.0.77
#tool nuget:?package=Alvecta.Foundation.Application.Ports.Testing&version=8.0.77
Alvecta.Foundation.Application.Ports.Testing
Test support for code written against
Alvecta.Foundation.Application.Ports:
fakes of the persistence ports. Reference it from a test project only; the Alvecta architecture
tests fail a product project that references a *.Testing package.
What it provides
InMemoryQueryableRepository<TEntity, TKey>(entities, keySelector)— anIQueryableRepository<TEntity, TKey>over a test's in-memory entities.Queryis the entities as an in-memory queryable, read anew on every call;Where,ByKey,GetSingleAsyncandExistsAsyncare built onQuerythe way the EF-backedQueryableRepositorybuilds them, andByKeylooks the key up with the sameKeyPredicate(fromApplication.Ports), so a value-object key matches by value.GetSingleAsyncthrowsInvalidOperationExceptionfor an unknown key, like EF'sSingleAsync.
It replaces the SetupReads Moq helper of the 6.3 packages (removed in 7.0): the package no longer
references Moq.
Usage
dotnet add package Alvecta.Foundation.Application.Ports.Testing
Import the namespace once for the whole test project, in GlobalUsings.cs:
global using Alvecta.Foundation.Application.Ports.Testing;
or in the test projects' Directory.Build.props:
<ItemGroup>
<Using Include="Alvecta.Foundation.Application.Ports.Testing" />
</ItemGroup>
Then hand the query session the fake, built from the test's data and the entity's key:
var orders = new InMemoryQueryableRepository<OrderView, OrderId>([pending, shipped], o => o.Id);
querySession.Setup(s => s.Orders).Returns(orders);
orders.ByKey(pending.Id); // pending
orders.Where(o => o.Status == OrderStatus.Shipped); // shipped
Limitations
- In-memory LINQ is not EF. A query EF cannot translate (
.Valueon a value object insideWhere, the keyed*Byset operators) still passes against the fake; only integration tests catch it. Nor does the fake reproduce EF-side guards such as a QuerySchema entity failing to materialize:GetSingleAsyncreturns the entity as given. - Async terminals. Query services that run
FirstOrDefaultAsyncand the like throughAlvecta.Utils.Queryable'sQueryableAsyncExtensionsstill need a synchronousIQueryableAsyncHelperregistered in the test project:SynchronousQueryableAsyncHelperfromAlvecta.Utils.Queryable.Testing, throughQueryableAsyncExtensions.UseAsyncHelper, typically in a[ModuleInitializer]. The fake replaces the repository, not that helper.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- Alvecta.Foundation.Application.Ports (>= 8.0.77)
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 |
|---|---|---|
| 9.6.96 | 0 | 11/25/2026 |
| 9.6.95 | 0 | 11/25/2026 |
| 9.6.94 | 48 | 11/24/2026 |
| 9.6.93 | 50 | 11/24/2026 |
| 9.5.92 | 59 | 11/24/2026 |
| 9.4.91 | 101 | 11/20/2026 |
| 9.3.90 | 95 | 11/13/2026 |
| 9.2.89 | 104 | 11/12/2026 |
| 9.1.88 | 97 | 11/11/2026 |
| 9.0.87 | 90 | 11/4/2026 |
| 9.0.86 | 84 | 11/4/2026 |
| 9.0.85 | 93 | 11/4/2026 |
| 9.0.84 | 96 | 11/4/2026 |
| 9.0.83 | 109 | 10/29/2026 |
| 9.0.82 | 104 | 10/29/2026 |
| 8.1.81 | 100 | 10/29/2026 |
| 8.0.80 | 101 | 10/28/2026 |
| 8.0.79 | 96 | 10/28/2026 |
| 8.0.78 | 111 | 10/28/2026 |
| 8.0.77 | 100 | 10/28/2026 |