Archetypical.Software.Vega.Api.IntegrationTests.Framework
2.7.1
dotnet add package Archetypical.Software.Vega.Api.IntegrationTests.Framework --version 2.7.1
NuGet\Install-Package Archetypical.Software.Vega.Api.IntegrationTests.Framework -Version 2.7.1
<PackageReference Include="Archetypical.Software.Vega.Api.IntegrationTests.Framework" Version="2.7.1" />
<PackageVersion Include="Archetypical.Software.Vega.Api.IntegrationTests.Framework" Version="2.7.1" />
<PackageReference Include="Archetypical.Software.Vega.Api.IntegrationTests.Framework" />
paket add Archetypical.Software.Vega.Api.IntegrationTests.Framework --version 2.7.1
#r "nuget: Archetypical.Software.Vega.Api.IntegrationTests.Framework, 2.7.1"
#:package Archetypical.Software.Vega.Api.IntegrationTests.Framework@2.7.1
#addin nuget:?package=Archetypical.Software.Vega.Api.IntegrationTests.Framework&version=2.7.1
#tool nuget:?package=Archetypical.Software.Vega.Api.IntegrationTests.Framework&version=2.7.1
Archetypical.Software.Vega.Api.IntegrationTests.Framework
Reusable integration-testing primitives for applications built on Archetypical.Software.Vega.Api.Abstractions.
This package provides:
- A lightweight in-process Vega API host backed by
Microsoft.AspNetCore.TestHost. - A set of docker-backed database fixtures (via
Testcontainers) for common providers. - Small xUnit helpers for skipping tests when Docker/Testcontainers is unavailable.
Installation
Reference the package from your test project:
<ItemGroup>
<PackageReference Include="Archetypical.Software.Vega.Api.IntegrationTests.Framework" Version="<version>" />
</ItemGroup>
Vega test host
Minimal usage
The host starts a VegaApiApplication in-memory (TestServer) and returns:
WebApplication AppHttpClient Client
using Archetypical.Software.Vega.Api.IntegrationTests.Framework.Hosting;
var (app, client) = await VegaTestHost.StartAsync(
new Dictionary<string, string?>
{
["VEGA:DBCONTEXT:PROVIDER"] = "INMEMORY"
},
options =>
{
options.ControllerAssemblies.Add(typeof(MyController).Assembly);
});
await using (app)
{
var resp = await client.GetAsync("/healthz");
resp.EnsureSuccessStatusCode();
}
Fluent builder
For more complex setups you can use a fluent builder:
using Archetypical.Software.Vega.Api.IntegrationTests.Framework.Hosting;
var (app, client) = await VegaTestHost.CreateBuilder()
.WithServiceName("MyService-IntegrationTests")
.AddConfiguration("VEGA:DBCONTEXT:PROVIDER", "SQLITE")
.AddConfiguration("VEGA:DBCONTEXT:CONNECTIONSTRING", "Data Source=:memory:")
.AddControllerAssembly(typeof(MyController).Assembly)
.WithEnsureCreated<MyDbContext>()
.StartAsync();
await using (app)
{
var resp = await client.GetAsync("/healthz");
resp.EnsureSuccessStatusCode();
}
Initialization hooks
If you need custom initialization (seeding data, schema, etc.), provide InitializeAsync:
options.InitializeAsync = async sp =>
{
using var scope = sp.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<MyDbContext>();
await db.Database.EnsureCreatedAsync();
};
You can also reuse the built-in helper:
options.InitializeAsync = VegaTestHost.EnsureCreatedWithRetry<MyDbContext>(attempts: 10, delaySeconds: 2);
Docker-backed database fixtures
All fixtures inherit DockerFixtureBase and expose:
bool IsAvailablestring? UnavailableReason
Use SkipIfUnavailable.Docker(fixture) at the start of tests to skip/guard when Docker is not reachable.
Postgres
using Archetypical.Software.Vega.Api.IntegrationTests.Framework.Fixtures;
using Archetypical.Software.Vega.Api.IntegrationTests.Framework.Utilities;
public class PostgresTests : IClassFixture<PostgresFixture>
{
private readonly PostgresFixture _fixture;
public PostgresTests(PostgresFixture fixture) => _fixture = fixture;
[Fact]
public async Task Works()
{
SkipIfUnavailable.Docker(_fixture);
var (app, client) = await VegaTestHost.StartAsync(
new Dictionary<string, string?>
{
["VEGA:DBCONTEXT:PROVIDER"] = "POSTGRESQL",
["VEGA:DBCONTEXT:CONNECTIONSTRING"] = _fixture.ConnectionString
},
options => options.ControllerAssemblies.Add(typeof(MyController).Assembly));
await using (app)
{
// ...
}
}
}
Optional configuration via builder:
var fixture = PostgresFixture.CreateBuilder()
.WithDatabase("vega")
.WithUsername("postgres")
.WithPassword("postgres")
.Build();
CockroachDB
var fixture = CockroachFixture.CreateBuilder()
.WithDatabase("defaultdb")
.Build();
SQL Server
var fixture = SqlServerFixture.CreateBuilder()
.WithPassword("yourStrong(!)Password")
.Build();
ClickHouse
var fixture = ClickhouseFixture.CreateBuilder()
.WithDatabase("default")
.WithReadyTimeoutSeconds(300)
.Build();
Notes
- This package targets
net9.0andnet10.0. - Docker-based tests should be written defensively; use
SkipIfUnavailable.Docker(...)to avoid false negatives on CI/dev machines without Docker. dotnet testshould be run against your test projects/solution; this package itself is not a test project.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- Archetypical.Software.Vega.Api.Abstractions (>= 2.7.1)
- Microsoft.AspNetCore.TestHost (>= 10.0.1)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.1)
- Testcontainers (>= 4.10.0)
- Testcontainers.ClickHouse (>= 4.10.0)
- Testcontainers.CockroachDb (>= 4.10.0)
- Testcontainers.MsSql (>= 4.10.0)
- Testcontainers.PostgreSql (>= 4.10.0)
- xunit (>= 2.9.3)
-
net9.0
- Archetypical.Software.Vega.Api.Abstractions (>= 2.7.1)
- Microsoft.AspNetCore.TestHost (>= 9.0.9)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.9)
- Testcontainers (>= 4.10.0)
- Testcontainers.ClickHouse (>= 4.10.0)
- Testcontainers.CockroachDb (>= 4.10.0)
- Testcontainers.MsSql (>= 4.10.0)
- Testcontainers.PostgreSql (>= 4.10.0)
- xunit (>= 2.9.3)
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 |
|---|---|---|
| 2.7.1 | 131 | 1/10/2026 |