Subatomix.Testing.SqlServerIntegration 4.0.0

dotnet add package Subatomix.Testing.SqlServerIntegration --version 4.0.0
                    
NuGet\Install-Package Subatomix.Testing.SqlServerIntegration -Version 4.0.0
                    
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="Subatomix.Testing.SqlServerIntegration" Version="4.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Subatomix.Testing.SqlServerIntegration" Version="4.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Subatomix.Testing.SqlServerIntegration" />
                    
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 Subatomix.Testing.SqlServerIntegration --version 4.0.0
                    
#r "nuget: Subatomix.Testing.SqlServerIntegration, 4.0.0"
                    
#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 Subatomix.Testing.SqlServerIntegration@4.0.0
                    
#: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=Subatomix.Testing.SqlServerIntegration&version=4.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Subatomix.Testing.SqlServerIntegration&version=4.0.0
                    
Install as a Cake Tool

About

Build Build NuGet NuGet

Provides easy temporary SQL Server databases for integration testing.

The top-level API surface of this package is the TestSqlServer static class, which sets up and tears down access to a local SQL Server instance. The class provides methods to generate and populate temporary databases on the instance. The class deletes the temporary databases as part of teardown.

TestSqlServer supports three scenarios, which its SetUp method attempts in order:

  • Existing Server via SQL Authentication

    If the environment variable MSSQL_SA_PASSWORD is defined, setup assumes that a local SQL Server default instance is running and that tests can authenticate as the system administrator (sa) using the given password.

  • Existing Server via Integrated Authentication

    Else, setup attempts to detect a local SQL Server default instance, assuming that the instance supports integrated authentication and that the current user has sufficient privileges to run tests.

  • Ephemeral Server

    Else, setup assumes that a docker command exists and can run Linux containers. Setup uses the command to start an ephemeral Linux SQL Server container with a random system administrator password.

A typical pattern is to use TestSqlServer from an NUnit setup fixture in a namespace that contains integration tests.

using Subatomix.Testing.SqlServerIntegration;

namespace MyProject.Tests.Integration;

[SetUpFixture]
public static class IntegrationTestsSetup
{
    private static TemporaryDatabase? _database;

    public static TemporaryDatabase Database
        => _database
        ?? throw new InvalidOperationException("SetUp has not executed.");

    [OneTimeSetUp]
    public static void SetUp()
    {
        // Discover a local SQL Server default instance, if any; else, spin up
        // a new instance in a Linux container
        TestSqlServer.SetUp();

        // Create a temporary database (as many as desired)
        _database = TestSqlServer.CreateTemporaryDatabase();

        // Set up the temporary database
        _database.Execute("-- your setup SQL here --");
    }

    [OneTimeTearDown]
    public static void TearDown()
    {
        // Delete temporary databases and stop the containerized instance if
        // created above
        TestSqlServer.TearDown();

        _database = null;
    }
}

The temporary databases are then available to all tests in the namespace.

[Test]
public void Foo()
{
    // The generated name of the temporary database
    _ = IntegrationTestsSetup.Database.Name;

    // The connection string for the temporary database
    _ = IntegrationTestsSetup.Database.ConnectionString;

    // A NetworkCredential (if SQL Authentication is used)
    _ = TestSqlServer.Credential;

    // A SqlCredential (if SQL Authentication is used)
    _ = TestSqlServer.SqlCredential;
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Framework net481 is compatible. 
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
4.0.0 593 12/1/2025
4.0.0-rc2 477 12/1/2025
4.0.0-rc1 406 12/1/2025
4.0.0-pre.5 195 11/10/2025
4.0.0-pre.4 161 11/9/2025
4.0.0-pre.3 104 11/9/2025
4.0.0-pre.2 144 11/4/2025