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
<PackageReference Include="Subatomix.Testing.SqlServerIntegration" Version="4.0.0" />
<PackageVersion Include="Subatomix.Testing.SqlServerIntegration" Version="4.0.0" />
<PackageReference Include="Subatomix.Testing.SqlServerIntegration" />
paket add Subatomix.Testing.SqlServerIntegration --version 4.0.0
#r "nuget: Subatomix.Testing.SqlServerIntegration, 4.0.0"
#:package Subatomix.Testing.SqlServerIntegration@4.0.0
#addin nuget:?package=Subatomix.Testing.SqlServerIntegration&version=4.0.0
#tool nuget:?package=Subatomix.Testing.SqlServerIntegration&version=4.0.0
About
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_PASSWORDis 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
dockercommand 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 | Versions 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. |
-
.NETFramework 4.8.1
- Microsoft.Data.SqlClient (>= 5.2.3 && < 6.0.0)
-
net6.0
- Microsoft.Data.SqlClient (>= 5.2.3 && < 6.0.0)
-
net8.0
- Microsoft.Data.SqlClient (>= 5.2.3 && < 6.0.0)
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 |