You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**PosInformatique.Testing.Databases** is a set of tools for testing databases.
8
11
It simplifies writing and executing tests, helping ensure your database and data access code are reliable and bug-free.
@@ -19,7 +22,10 @@ You can also use this tools to create and run integration tests with the
19
22
[Integration tests in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-8.0)
20
23
approach.
21
24
22
-
Since the version 2.0.0 this tools provide a comparer to compare the schema of two SQL databases.
25
+
### Main release improvements
26
+
- v2.0: This tools provide a comparer to compare the schema of two SQL databases.
27
+
- v3.0: Add new [PosInformatique.Testing.Databases.SqlServer.SqlCmd](https://www.nuget.org/packages/PosInformatique.Testing.Databases.SqlServer.SqlCmd) which allows
28
+
to deploy database using a T-SQL script with the SQL Server [sqlcmd utility](https://learn.microsoft.com/en-us/sql/tools/sqlcmd/sqlcmd-utility).
23
29
24
30
## 💡 The approach of these tools
25
31
@@ -46,9 +52,10 @@ Before each test (`TestMethod` or `Fact` methods):
46
52
47
53
1. Create an empty database with the SQL schema of the application.
48
54
49
-
There are two ways to do this:
50
-
- Deploy a DACPAC file (built by a SQL Server Database project).
51
-
- Or create a database from a `DbContext` using Entity Framework.
55
+
There are three ways to do this:
56
+
- Deploy a DACPAC file (built by a SQL Server Database project) using [PosInformatique.Testing.Databases.SqlServer.Dac](https://www.nuget.org/packages/PosInformatique.Testing.Databases.SqlServer.Dac) library.
57
+
- Create a database from a `DbContext` using Entity Framework using [PosInformatique.Testing.Databases.SqlServer.EntityFramework](https://www.nuget.org/packages/PosInformatique.Testing.Databases.SqlServer.EntityFramework) library.
58
+
- Or create a database since a T-SQL script file using [PosInformatique.Testing.Databases.SqlServer.SqlCmd](https://www.nuget.org/packages/PosInformatique.Testing.Databases.SqlServer.SqlCmd) library
52
59
53
60
2. Fill the tables with the sample data needed.
54
61
@@ -69,19 +76,21 @@ To perform tests of a database migration, the approach is straightforward and re
69
76
70
77
2. Create a secondary database with the targeted schema (*target database*).
71
78
72
-
There are two ways to do this:
73
-
- Deploy a DACPAC file (built by a SQL Server Database project).
74
-
- Or create a database from a `DbContext` using Entity Framework.
79
+
There are three ways to do this:
80
+
- Deploy a DACPAC file (built by a SQL Server Database project) using [PosInformatique.Testing.Databases.SqlServer.Dac](https://www.nuget.org/packages/PosInformatique.Testing.Databases.SqlServer.Dac) library.
81
+
- Create a database from a `DbContext` using Entity Framework using [PosInformatique.Testing.Databases.SqlServer.EntityFramework](https://www.nuget.org/packages/PosInformatique.Testing.Databases.SqlServer.EntityFramework) library.
82
+
- Or create a database since a T-SQL script file using [PosInformatique.Testing.Databases.SqlServer.SqlCmd](https://www.nuget.org/packages/PosInformatique.Testing.Databases.SqlServer.SqlCmd) library
75
83
76
84
3. Execute your database *migration code* on the *initial database*.
77
85
78
86
Your database *migration code* can be:
79
87
- A simple SQL script file.
80
88
- An Entity Framework migration sets executed with the `MigrateAsync()` method.
89
+
- Or any other way that you usually use to migrate the schema of your database.
81
90
82
91
4. Compare the two databases schemas (*initial* and *target*).
83
92
84
-
If the database *migration code* works, the *initial* and *target* must have the same schema.
93
+
If the database *migration code* works, the *initial* and *target* must have **EXACTLY**the same schema.
85
94
86
95
> **NB**: The initial database is not necessarily empty. It can be at a specific schema version X if we want to test the migration from version X to Y.
87
96
@@ -119,6 +128,10 @@ The [PosInformatique.Testing.Databases](https://github.com/PosInformatique/PosIn
119
128
-[PosInformatique.Testing.Databases.SqlServer.EntityFramework](https://www.nuget.org/packages/PosInformatique.Testing.Databases.SqlServer.EntityFramework) NuGet package which contains:
120
129
- Tools to deploy a SQL Server database using a DbContext.
121
130
131
+
-[PosInformatique.Testing.Databases.SqlServer.SqlCmd](https://www.nuget.org/packages/PosInformatique.Testing.Databases.SqlServer.SqlCmd) NuGet package which contains:
132
+
- Tools to execute T-SQL script using the SQL Server [sqlcmd utility](https://learn.microsoft.com/en-us/sql/tools/sqlcmd/sqlcmd-utility). This script can be use to deploy a
133
+
SQL Server database.
134
+
122
135
## 🚀 Samples / Demo
123
136
124
137
A complete sample solution is available in this repository inside the [samples](./samples) folder.
@@ -160,3 +173,27 @@ For Entity Framework migration:
160
173
-[Add the NuGet packages](./docs/WriteDatabaseMigrationTest.md#add-the-nuget-packages)
161
174
-[Write test to check the migration of the database](./docs/WriteDatabaseMigrationTest.md#write-test-to-check-the-migration-of-the-database)
162
175
-[Check the report details of the `SqlServerDatabaseComparer` tool](./docs/WriteDatabaseMigrationTest.md#check-the-report-details-of-the-sqlserverdatabasecomparer-tool)
176
+
177
+
## 📦 NuGet package dependency versions
178
+
179
+
These tools rely on a minimal set of NuGet dependencies to ensure broad compatibility.
180
+
They are built for **.NET 6.0** but also work seamlessly with newer versions of .NET:
181
+
182
+
- .NET 7.0
183
+
- .NET 8.0
184
+
- .NET 9.0
185
+
- .NET 10.0
186
+
187
+
### Dependency versions
188
+
189
+
All NuGet packages depend on **low baseline versions** of Microsoft libraries to remain compatible with any modern version:
We recommend using the **latest versions** of these libraries in your own projects to benefit from the most recent features, performance improvements, and security fixes.
0 commit comments