DbMocker 1.4.1-alpha

This .NET library simplifies data mocking for UnitTests, to avoid a connection to a relational database.
DbMocker use the standard Microsoft .NET DbConnection object. So, you can mock any toolkit,
including EntityFramework, Dapper or ADO.NET; And for all database servers (SQL Server, Oracle, SQLite).

var conn = new MockDbConnection();
conn.Mocks.WhenAny()..ReturnsScalar(14);

This is a prerelease version of DbMocker.
There is a newer version of this package available.
See the version list below for details.
Install-Package DbMocker -Version 1.4.1-alpha
dotnet add package DbMocker --version 1.4.1-alpha
<PackageReference Include="DbMocker" Version="1.4.1-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DbMocker --version 1.4.1-alpha
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Preview of version 1.5: See GitHub.

  • Add a MockColumn class to manage the column type. See example using "typed columns" above.
  • Breaking change: to allow typed MockColumn, the property MockTable.Columns is now of type MockColumn[] (previously string[]).

Returns a table using a MockTable.WithColumns() typed columns. In this case, columns are defined using a tuple (ColumnName, ColumnType).

conn.Mocks
    .WhenAny()
    .ReturnsTable(MockTable.WithColumns(("ID", typeof(int?), 
                                        ("Name", typeof(string)))
                           .AddRow(null, "Scott")
                           .AddRow(2,    "Bill"));

Preview of version 1.5: See GitHub.

  • Add a MockColumn class to manage the column type. See example using "typed columns" above.
  • Breaking change: to allow typed MockColumn, the property MockTable.Columns is now of type MockColumn[] (previously string[]).

Returns a table using a MockTable.WithColumns() typed columns. In this case, columns are defined using a tuple (ColumnName, ColumnType).

conn.Mocks
    .WhenAny()
    .ReturnsTable(MockTable.WithColumns(("ID", typeof(int?), 
                                        ("Name", typeof(string)))
                           .AddRow(null, "Scott")
                           .AddRow(2,    "Bill"));

Release Notes

https://github.com/Apps72/DbMocker

  • .NETCoreApp 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.11.0 52 11/23/2020
1.10.0 57 11/23/2020
1.9.0 52 11/12/2020
1.8.0 65 11/11/2020
1.7.0-Preview2 181 5/20/2020
1.7.0-Preview1 134 5/20/2020
1.6.0 12,781 4/17/2019
1.5.0 807 9/2/2018
1.4.1-alpha 297 8/29/2018
1.4.0 366 8/5/2018
1.3.0 383 8/2/2018
1.2.0 366 7/31/2018
1.1.0 467 7/15/2018
Show less