Codibre.SqlServerMock 0.1.2

dotnet add package Codibre.SqlServerMock --version 0.1.2                
NuGet\Install-Package Codibre.SqlServerMock -Version 0.1.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Codibre.SqlServerMock" Version="0.1.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Codibre.SqlServerMock --version 0.1.2                
#r "nuget: Codibre.SqlServerMock, 0.1.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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                

Actions Status Actions Status Actions Status benchmark Test Coverage Maintainability

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.2 1,079 3/5/2024
0.1.1 238 1/15/2024
0.1.0 109 1/15/2024
0.0.1 110 1/15/2024