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
                    
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="Archetypical.Software.Vega.Api.IntegrationTests.Framework" Version="2.7.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Archetypical.Software.Vega.Api.IntegrationTests.Framework" Version="2.7.1" />
                    
Directory.Packages.props
<PackageReference Include="Archetypical.Software.Vega.Api.IntegrationTests.Framework" />
                    
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 Archetypical.Software.Vega.Api.IntegrationTests.Framework --version 2.7.1
                    
#r "nuget: Archetypical.Software.Vega.Api.IntegrationTests.Framework, 2.7.1"
                    
#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 Archetypical.Software.Vega.Api.IntegrationTests.Framework@2.7.1
                    
#: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=Archetypical.Software.Vega.Api.IntegrationTests.Framework&version=2.7.1
                    
Install as a Cake Addin
#tool nuget:?package=Archetypical.Software.Vega.Api.IntegrationTests.Framework&version=2.7.1
                    
Install as a Cake Tool

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 App
  • HttpClient 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 IsAvailable
  • string? 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.0 and net10.0.
  • Docker-based tests should be written defensively; use SkipIfUnavailable.Docker(...) to avoid false negatives on CI/dev machines without Docker.
  • dotnet test should be run against your test projects/solution; this package itself is not a test project.
Product 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. 
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
2.7.1 131 1/10/2026