Codibre.SqlServerMock
0.1.2
dotnet add package Codibre.SqlServerMock --version 0.1.2
NuGet\Install-Package Codibre.SqlServerMock -Version 0.1.2
<PackageReference Include="Codibre.SqlServerMock" Version="0.1.2" />
paket add Codibre.SqlServerMock --version 0.1.2
#r "nuget: Codibre.SqlServerMock, 0.1.2"
// Install Codibre.SqlServerMock as a Cake Addin #addin nuget:?package=Codibre.SqlServerMock&version=0.1.2 // Install Codibre.SqlServerMock as a Cake Tool #tool nuget:?package=Codibre.SqlServerMock&version=0.1.2
SqlServer mocking library for unit tests that uses Sqlite in-memory under the hood.
Why
Although one can argue that having a in memory real database is not unit testing, the results of using such approach for repositories unit tests is way better than mocking it using a IEnumerable, specially when working with Dapper.
How to use it
First, import the application namespace:
using Codibre.SqlServerMock
Now, create your connection using MssqlMockDbConnection. You'll need to create every table entity using SqlLite commands in your unit tests. For now, this library will only work with a limited number of SELECT queries.
Here's a list of idiomatics differences already treated here:
- TOP ⇒ LIMIT;
- (NOLOCK) ⇒ Removed as Sqlite doesn't have anything like that;
- CONCAT Function ⇒ Little hacky but replaced using regex by || operator. Need to be refactored by using parsed TSqlFragment;
What comes next?
Anything that comes in the way of unit testing sql server repositories can be converted here, but be aware, that this library has no intention at all of reflecting every possible SQL Server functionality using in-memory SqlLite: it is absolutely impossible! But we believe is commom sense that the most commom used ones are expected to be possible to convert. Although we know that not everything will be possible to cover, having a least a good part of the repository layer unit tested, can really put the quality of a project to another level!
License
Licensed under MIT.
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. net8.0 was computed. 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. |
-
net7.0
- Microsoft.Data.Sqlite (>= 8.0.1)
- Microsoft.SqlServer.TransactSql.ScriptDom (>= 161.8910.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.