DynamicEndpoints.Testing
0.3.0
See the version list below for details.
dotnet add package DynamicEndpoints.Testing --version 0.3.0
NuGet\Install-Package DynamicEndpoints.Testing -Version 0.3.0
<PackageReference Include="DynamicEndpoints.Testing" Version="0.3.0" />
<PackageVersion Include="DynamicEndpoints.Testing" Version="0.3.0" />
<PackageReference Include="DynamicEndpoints.Testing" />
paket add DynamicEndpoints.Testing --version 0.3.0
#r "nuget: DynamicEndpoints.Testing, 0.3.0"
#:package DynamicEndpoints.Testing@0.3.0
#addin nuget:?package=DynamicEndpoints.Testing&version=0.3.0
#tool nuget:?package=DynamicEndpoints.Testing&version=0.3.0
DynamicEndpoints.Testing
Test helpers for DynamicEndpoints. Run your dynamic endpoints in
WebApplicationFactory, or on a small test server, without PostgreSQL or any other database.
Your application, in memory
await using var factory = new WebApplicationFactory<Program>()
.WithInMemoryDynamicEndpoints(b => b.AddProcessor("fake-crm", _ => Results.Ok(new { id = 1 })));
await factory.AddDynamicEndpointAsync(DynamicEndpoint.Get("/customers/{id}").HandledBy("fake-crm").FromRoute("id"));
var response = await factory.CreateClient().GetAsync("/customers/1");
WithInMemoryDynamicEndpoints swaps the store for an in-memory one. It also removes store initializers (migrations), change
notifiers and polling. Your seeders still run, against the in-memory store. In your own ConfigureTestServices it's
services.UseInMemoryDynamicEndpoints().
Just your processors and validators
await using var server = await DynamicEndpointsTestServer.StartAsync(b => b
.AddProcessor<OrderLookupProcessor>()
.AddValidator<NipValidator>());
await server.AddEndpointAsync(DynamicEndpoint.Get("/orders/{id}").HandledBy<OrderLookupProcessor>().FromRoute("id"));
var order = await server.Client.GetFromJsonAsync<Order>("/orders/42");
var openApi = server.OpenApi.GetDocument();
Several instances
Share one InMemoryDynamicEndpointStore and one InMemoryDynamicEndpointChangeNotifier between servers:
var store = new InMemoryDynamicEndpointStore();
var notifier = new InMemoryDynamicEndpointChangeNotifier();
var options = new DynamicEndpointsTestServerOptions { Store = store, DynamicEndpoints = b => b.UseChangeNotifier(notifier) };
await using var a = await DynamicEndpointsTestServer.StartAsync(options);
await using var b = await DynamicEndpointsTestServer.StartAsync(options);
๐ Documentation ยท ๐ Changelog
| 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
- DynamicEndpoints (>= 0.3.0)
- Microsoft.AspNetCore.Mvc.Testing (>= 10.0.12)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.