DacHelpers 0.0.2-alpha2
See the version list below for details.
dotnet add package DacHelpers --version 0.0.2-alpha2
NuGet\Install-Package DacHelpers -Version 0.0.2-alpha2
<PackageReference Include="DacHelpers" Version="0.0.2-alpha2" />
paket add DacHelpers --version 0.0.2-alpha2
#r "nuget: DacHelpers, 0.0.2-alpha2"
// Install DacHelpers as a Cake Addin
#addin nuget:?package=DacHelpers&version=0.0.2-alpha2&prerelease
// Install DacHelpers as a Cake Tool
#tool nuget:?package=DacHelpers&version=0.0.2-alpha2&prerelease
DacHelpers
Wrapper for Microsoft.SqlServer.Dac and Docker.DotNet to simplify integration testing against databases with DacPacs.
Usage
To deploy a DacPac to localhost or to local docker simply supply a path and a name. Note that it drops the existing database first.
var dacpacPath = "TestDb.dacpac";
var databaseName = "TestDb";
var testDatabaseHelper = await DacHelper.DropAndDeployLocalAsync(dacpacPath, databaseName);
//Or
var testDatabaseHelper = await DacHelper.DropAndDeployDockerAsync(dacpacPath, databaseName);
The databaseTestHelper has a few helper functions to aid tests like supplying connectionstrings, resetting the database or cleaning up after use:
var connectionString = testDatabaseHelper.GetConnectionString();
await testDatabaseHelper.ResetDatabaseAsync();
await testDatabaseHelper.CleanUpAsync();
If using SqlCmd variables in the DacPac you can supply a dictionary with mappings:
var variableMap = new Dictionary<string, string>() { { "Registration", "Registration" } }
var testDatabaseHelper = DacHelper.DropAndDeployDockerAsync(dacpacPath, databaseName, variableMap);
To deploy a list of changescripts instead of a DacPac locally:
var folder = "changescripts/"
var changescripts = new List<string> = { $"{folder}001-addSchemas.sql", $"{folder}002-addEmployeeTable", $"{folder}003-addOfficeTable" }
await DacHelper.DeployChangescriptsLocalAsync(databaseName, changescripts);
Or to simply deploy a folder of changescripts locally (in alphabetical order):
var folder = "changescripts/"
await DacHelper.DeployChangescriptsLocalAsync(databaseName, folder);
Testing that a list of changescripts match a DacPac is as simple as:
var changes = await DacHelper.CompareLocalAsync(dacpacPath, changescriptFolder);
Assert.That(changes, Has.Count.EqualTo(0));
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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. |
-
net7.0
- Microsoft.Data.SqlClient (>= 5.0.1)
- Microsoft.SqlServer.DacFx (>= 161.6374.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 |
---|---|---|
0.0.3-alpha1 | 67 | 1/8/2023 |
0.0.2-alpha6 | 67 | 12/21/2022 |
0.0.2-alpha5 | 66 | 12/11/2022 |
0.0.2-alpha4 | 66 | 12/8/2022 |
0.0.2-alpha3 | 73 | 12/8/2022 |
0.0.2-alpha2 | 70 | 12/8/2022 |
0.0.2-alpha1 | 65 | 12/7/2022 |
0.0.1-alpha1 | 71 | 12/6/2022 |