Skip to content

Commit fa83397

Browse files
v3.0.0 (#13)
* Updates the CreateEmptyDatabase() to specify the location of the database to create. * Add the support in SqlServerDacExtensions to deploy database in a specific folder. * Update the SqlServerDacDatabaseInitializer to add the support of additional settings to specify the locations of the database. * Add SqlCmd library. * Add guard to public APIs. * Changes the connection strings to retrieve from env variable and after use localdb if no env variable exists. * Use the MSBuild.Sdk.SqlProj for the database projects. * Migrate to xUnit v3. * Enable analyzers code in Release
1 parent f35abb8 commit fa83397

File tree

67 files changed

+2357
-485
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2357
-485
lines changed

.github/workflows/github-actions-ci.yaml

Lines changed: 64 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,78 @@ on:
88

99
jobs:
1010
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
checks: write
14+
pull-requests: write
15+
services:
16+
sqlserver:
17+
image: mcr.microsoft.com/mssql/server:2022-latest
18+
env:
19+
SA_PASSWORD: "P@ssw0rd12345!"
20+
ACCEPT_EULA: "Y"
21+
ports:
22+
- 1433:1433
23+
volumes:
24+
- /tmp/other_databases_path:/tmp/other_databases_path
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Setup .NET
29+
uses: actions/setup-dotnet@v4
30+
with:
31+
dotnet-version: 8.0.x
32+
33+
- name: Restore dependencies
34+
run: dotnet restore PosInformatique.Testing.Databases.sln
35+
36+
- name: Build solution
37+
run: dotnet build PosInformatique.Testing.Databases.sln --configuration Release --no-restore
38+
39+
- name: Install SQL Server command-line tools
40+
run: |
41+
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
42+
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
43+
sudo apt-get update
44+
sudo apt-get install -y mssql-tools
45+
echo "/opt/mssql-tools/bin" >> $GITHUB_PATH
46+
47+
- name: Prepare SQL databases directory
48+
run: |
49+
# Give the rights to the 'mssql' user to read/write in the /tmp/other_databases_path directory.
50+
docker exec --user root $(docker ps -qf "ancestor=mcr.microsoft.com/mssql/server:2022-latest") chown -R mssql:mssql /tmp/other_databases_path
51+
52+
- name: Run tests
53+
run: |
54+
dotnet test PosInformatique.Testing.Databases.sln \
55+
--configuration Release \
56+
--no-build \
57+
--logger "trx;LogFileName=test_results.trx" \
58+
--results-directory ./TestResults
59+
env:
60+
SQL_SERVER_UNIT_TESTS_CONNECTION_STRING: "Data Source=localhost,1433;Database=master;User Id=sa;Password=P@ssw0rd12345!;TrustServerCertificate=True;"
61+
SQL_SERVER_UNIT_TESTS_OTHER_DATA_PATH: "/tmp/other_databases_path/"
62+
63+
- name: Publish Test Results
64+
uses: EnricoMi/publish-unit-test-result-action@v2
65+
if: (!cancelled())
66+
with:
67+
files: |
68+
TestResults/**/*.trx
69+
70+
build-samples:
1171
runs-on: windows-latest
1272
steps:
1373
- uses: actions/checkout@v4
1474

1575
- name: Setup NuGet
1676
uses: nuget/setup-nuget@v2
1777

18-
- name: Restore NuGet packages
19-
run: nuget restore PosInformatique.Testing.Databases.sln
20-
78+
- name: Restore NuGet packages of the samples
79+
run: nuget restore samples/PosInformatique.Testing.Databases.Samples.sln
80+
2181
- name: Add msbuild to PATH
2282
uses: microsoft/setup-msbuild@v2
2383

24-
- name: Build
25-
run: msbuild "PosInformatique.Testing.Databases.sln" /p:Configuration=Debug
26-
27-
- name: Restore NuGet packages
28-
run: nuget restore "samples/PosInformatique.Testing.Databases.Samples.sln"
29-
30-
- name: Build the samples
84+
- name: Build samples with Visual Studio
3185
run: msbuild "samples/PosInformatique.Testing.Databases.Samples.sln" /p:Configuration=Debug
32-
33-
- name: Creates the LocalDB for the tests
34-
shell: cmd
35-
run: SqlLocalDB create posinfo-tests
36-
37-
- name: Creates the SQL Login service accounts for the tests
38-
shell: cmd
39-
run: sqlcmd -S "(localDB)\posinfo-tests" -Q "IF NOT EXISTS (SELECT 1 FROM [sys].[server_principals] WHERE [Name] = 'ServiceAccountLogin') CREATE LOGIN [ServiceAccountLogin] WITH PASSWORD = 'P@ssw0rd'"
40-
41-
# Use this fix https://github.com/microsoft/vstest-action/issues/31#issuecomment-2159463764
42-
- name: Test with the dotnet CLI
43-
uses: rusty-bender/vstest-action@main
44-
with:
45-
searchFolder: .\
46-
testAssembly: |
47-
/tests/**/*tests.dll
48-
!./**/*TestAdapter.dll
49-
!./**/obj/**

.github/workflows/github-actions-release.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ on:
77
type: string
88
description: The version of the library
99
required: true
10-
default: 2.3.0
10+
default: 3.0.0
1111
VersionSuffix:
1212
type: string
1313
description: The version suffix of the library (for example rc.1)
1414

15-
run-name: ${{ inputs.VersionPrefix }}-${{ inputs.VersionSuffix }}
15+
run-name: ${{ inputs.VersionSuffix && format('{0}-{1}', inputs.VersionPrefix, inputs.VersionSuffix) || inputs.VersionPrefix }}
1616

1717
jobs:
1818
build:
@@ -32,19 +32,26 @@ jobs:
3232
--property:VersionSuffix=${{ github.event.inputs.VersionSuffix }}
3333
"src/Testing.Databases.SqlServer/Testing.Databases.SqlServer.csproj"
3434

35+
- name: Build Testing.Databases.SqlServer.Dac
36+
run: dotnet pack
37+
--property:Configuration=Release
38+
--property:VersionPrefix=${{ github.event.inputs.VersionPrefix }}
39+
--property:VersionSuffix=${{ github.event.inputs.VersionSuffix }}
40+
"src/Testing.Databases.SqlServer.Dac/Testing.Databases.SqlServer.Dac.csproj"
41+
3542
- name: Build Testing.Databases.SqlServer.EntityFramework
3643
run: dotnet pack
3744
--property:Configuration=Release
3845
--property:VersionPrefix=${{ github.event.inputs.VersionPrefix }}
3946
--property:VersionSuffix=${{ github.event.inputs.VersionSuffix }}
4047
"src/Testing.Databases.SqlServer.EntityFramework/Testing.Databases.SqlServer.EntityFramework.csproj"
4148

42-
- name: Build Testing.Databases.SqlServer.Dac
49+
- name: Build Testing.Databases.SqlServer.SqlCmd
4350
run: dotnet pack
4451
--property:Configuration=Release
4552
--property:VersionPrefix=${{ github.event.inputs.VersionPrefix }}
4653
--property:VersionSuffix=${{ github.event.inputs.VersionSuffix }}
47-
"src/Testing.Databases.SqlServer.Dac/Testing.Databases.SqlServer.Dac.csproj"
54+
"src/Testing.Databases.SqlServer.SqlCmd/Testing.Databases.SqlServer.SqlCmd.csproj"
4855

4956
- name: Publish the package to nuget.org
5057
run: dotnet nuget push "src/**/bin/Release/*.nupkg" --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json

Directory.Build.props

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
<!-- Enable implict usings -->
1616
<ImplicitUsings>enable</ImplicitUsings>
1717

18-
<!-- Disable the Analyzers in Release configuration -->
19-
<RunAnalyzers Condition="'$(Configuration)' == 'Release'">false</RunAnalyzers>
20-
2118
<!-- Disable the StyleCop 'XML comment analysis is disabled due to project configuration' warning. -->
2219
<NoWarn>$(NoWarn);SA0001;NU1903</NoWarn>
2320

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
1313
<PackageVersion Include="Microsoft.SqlServer.DacFx" Version="162.1.172" />
1414
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
15-
<PackageVersion Include="xunit" Version="2.9.3" />
15+
<PackageVersion Include="xunit.v3" Version="3.0.1" />
1616
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.4" />
1717
</ItemGroup>
1818
</Project>

PosInformatique.Testing.Databases.sln

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{49103176-7D0
3131
src\Directory.Build.props = src\Directory.Build.props
3232
EndProjectSection
3333
EndProject
34-
Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "Testing.Databases.SqlServer.Tests.DacPac", "tests\Testing.Databases.SqlServer.Tests.DacPac\Testing.Databases.SqlServer.Tests.DacPac.sqlproj", "{5F618225-0E1C-46A7-BBCC-23A6243D5CEE}"
34+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Testing.Databases.SqlServer.Tests.DacPac", "tests\Testing.Databases.SqlServer.Tests.DacPac\Testing.Databases.SqlServer.Tests.DacPac.csproj", "{5F618225-0E1C-46A7-BBCC-23A6243D5CEE}"
3535
EndProject
3636
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{91BFD2B1-6AB6-4B07-9D2E-430C93F150D4}"
3737
EndProject
@@ -41,22 +41,32 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
4141
.github\workflows\github-actions-release.yml = .github\workflows\github-actions-release.yml
4242
EndProjectSection
4343
EndProject
44-
Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "Testing.Databases.SqlServer.Tests.Source", "tests\Testing.Databases.SqlServer.Tests.Source\Testing.Databases.SqlServer.Tests.Source.sqlproj", "{A261D4FF-9BEA-475C-8671-E9BACFDCE960}"
44+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Testing.Databases.SqlServer.Tests.Source", "tests\Testing.Databases.SqlServer.Tests.Source\Testing.Databases.SqlServer.Tests.Source.csproj", "{A261D4FF-9BEA-475C-8671-E9BACFDCE960}"
4545
EndProject
46-
Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "Testing.Databases.SqlServer.Tests.Target", "tests\Testing.Databases.SqlServer.Tests.Target\Testing.Databases.SqlServer.Tests.Target.sqlproj", "{6CD3F177-053F-4816-A37E-5CA6F293D34C}"
46+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Testing.Databases.SqlServer.Tests.Target", "tests\Testing.Databases.SqlServer.Tests.Target\Testing.Databases.SqlServer.Tests.Target.csproj", "{6CD3F177-053F-4816-A37E-5CA6F293D34C}"
4747
EndProject
4848
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Testing.Databases.SqlServer.EntityFramework", "src\Testing.Databases.SqlServer.EntityFramework\Testing.Databases.SqlServer.EntityFramework.csproj", "{157DDF0D-9410-4646-94B9-9CEE4C140F5E}"
4949
EndProject
5050
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Testing.Databases.SqlServer.EntityFramework.Tests", "tests\Testing.Databases.SqlServer.EntityFramework.Tests\Testing.Databases.SqlServer.EntityFramework.Tests.csproj", "{04A7AE8F-FE77-435B-9250-600388BB8065}"
5151
EndProject
5252
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{8500A9B6-CAA0-432C-BABB-DDC86CE08994}"
5353
ProjectSection(SolutionItems) = preProject
54-
docs\WriteTest.md = docs\WriteTest.md
5554
docs\WriteDatabaseMigrationTest.md = docs\WriteDatabaseMigrationTest.md
55+
docs\WriteTest.md = docs\WriteTest.md
5656
EndProjectSection
5757
EndProject
5858
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Testing.Databases.SqlServer.Dac", "src\Testing.Databases.SqlServer.Dac\Testing.Databases.SqlServer.Dac.csproj", "{8BE60460-EBA5-43DE-B85D-C756E2988DC8}"
5959
EndProject
60+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testing.Databases.SqlServer.Dac.Tests", "tests\Testing.Databases.SqlServer.Dac.Tests\Testing.Databases.SqlServer.Dac.Tests.csproj", "{6751A585-1BB0-49A1-BF68-D7FBD3392DF6}"
61+
EndProject
62+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testing.Databases.SqlServer.SqlCmd", "src\Testing.Databases.SqlServer.SqlCmd\Testing.Databases.SqlServer.SqlCmd.csproj", "{D3004122-CCDD-4EAD-BD9E-DA6DFF470943}"
63+
EndProject
64+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testing.Databases.SqlServer.SqlCmd.Tests", "tests\Testing.Databases.SqlServer.SqlCmd.Tests\Testing.Databases.SqlServer.SqlCmd.Tests.csproj", "{F8E025D7-4E2F-437A-ABFA-C43A1368E15A}"
65+
EndProject
66+
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Testing.Databases.SqlServer.Shared", "src\Testing.Databases.SqlServer.Shared\Testing.Databases.SqlServer.Shared.shproj", "{B9F8C52D-4652-4FC6-A695-DC2F61BA05C9}"
67+
EndProject
68+
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Testing.Databases.SqlServer.Shared.Tests", "tests\Testing.Databases.SqlServer.Shared.Tests\Testing.Databases.SqlServer.Shared.Tests.shproj", "{1554EA1B-37C8-4F10-9770-BF4DD8A7E80C}"
69+
EndProject
6070
Global
6171
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6272
Debug|Any CPU = Debug|Any CPU
@@ -101,6 +111,18 @@ Global
101111
{8BE60460-EBA5-43DE-B85D-C756E2988DC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
102112
{8BE60460-EBA5-43DE-B85D-C756E2988DC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
103113
{8BE60460-EBA5-43DE-B85D-C756E2988DC8}.Release|Any CPU.Build.0 = Release|Any CPU
114+
{6751A585-1BB0-49A1-BF68-D7FBD3392DF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
115+
{6751A585-1BB0-49A1-BF68-D7FBD3392DF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
116+
{6751A585-1BB0-49A1-BF68-D7FBD3392DF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
117+
{6751A585-1BB0-49A1-BF68-D7FBD3392DF6}.Release|Any CPU.Build.0 = Release|Any CPU
118+
{D3004122-CCDD-4EAD-BD9E-DA6DFF470943}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
119+
{D3004122-CCDD-4EAD-BD9E-DA6DFF470943}.Debug|Any CPU.Build.0 = Debug|Any CPU
120+
{D3004122-CCDD-4EAD-BD9E-DA6DFF470943}.Release|Any CPU.ActiveCfg = Release|Any CPU
121+
{D3004122-CCDD-4EAD-BD9E-DA6DFF470943}.Release|Any CPU.Build.0 = Release|Any CPU
122+
{F8E025D7-4E2F-437A-ABFA-C43A1368E15A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
123+
{F8E025D7-4E2F-437A-ABFA-C43A1368E15A}.Debug|Any CPU.Build.0 = Debug|Any CPU
124+
{F8E025D7-4E2F-437A-ABFA-C43A1368E15A}.Release|Any CPU.ActiveCfg = Release|Any CPU
125+
{F8E025D7-4E2F-437A-ABFA-C43A1368E15A}.Release|Any CPU.Build.0 = Release|Any CPU
104126
EndGlobalSection
105127
GlobalSection(SolutionProperties) = preSolution
106128
HideSolutionNode = FALSE
@@ -115,4 +137,15 @@ Global
115137
GlobalSection(ExtensibilityGlobals) = postSolution
116138
SolutionGuid = {FAC64573-D665-48A8-AC75-7B82B692EC9E}
117139
EndGlobalSection
140+
GlobalSection(SharedMSBuildProjectFiles) = preSolution
141+
tests\Testing.Databases.SqlServer.Shared.Tests\Testing.Databases.SqlServer.Shared.Tests.projitems*{04a7ae8f-fe77-435b-9250-600388bb8065}*SharedItemsImports = 5
142+
tests\Testing.Databases.SqlServer.Shared.Tests\Testing.Databases.SqlServer.Shared.Tests.projitems*{1554ea1b-37c8-4f10-9770-bf4dd8a7e80c}*SharedItemsImports = 13
143+
src\Testing.Databases.SqlServer.Shared\Testing.Databases.SqlServer.Shared.projitems*{157ddf0d-9410-4646-94b9-9cee4c140f5e}*SharedItemsImports = 5
144+
tests\Testing.Databases.SqlServer.Shared.Tests\Testing.Databases.SqlServer.Shared.Tests.projitems*{6751a585-1bb0-49a1-bf68-d7fbd3392df6}*SharedItemsImports = 5
145+
src\Testing.Databases.SqlServer.Shared\Testing.Databases.SqlServer.Shared.projitems*{8be60460-eba5-43de-b85d-c756e2988dc8}*SharedItemsImports = 5
146+
src\Testing.Databases.SqlServer.Shared\Testing.Databases.SqlServer.Shared.projitems*{b9f8c52d-4652-4fc6-a695-dc2f61ba05c9}*SharedItemsImports = 13
147+
tests\Testing.Databases.SqlServer.Shared.Tests\Testing.Databases.SqlServer.Shared.Tests.projitems*{c87e8f0d-d96d-4d77-9713-5564dc2e3597}*SharedItemsImports = 5
148+
src\Testing.Databases.SqlServer.Shared\Testing.Databases.SqlServer.Shared.projitems*{d3004122-ccdd-4ead-bd9e-da6dff470943}*SharedItemsImports = 5
149+
tests\Testing.Databases.SqlServer.Shared.Tests\Testing.Databases.SqlServer.Shared.Tests.projitems*{f8e025d7-4e2f-437a-abfa-c43a1368e15a}*SharedItemsImports = 5
150+
EndGlobalSection
118151
EndGlobal

0 commit comments

Comments
 (0)