![]() |
VOOZH | about |
dotnet add package MockQueryable.Core --version 10.0.8
NuGet\Install-Package MockQueryable.Core -Version 10.0.8
<PackageReference Include="MockQueryable.Core" Version="10.0.8" />
<PackageVersion Include="MockQueryable.Core" Version="10.0.8" />Directory.Packages.props
<PackageReference Include="MockQueryable.Core" />Project file
paket add MockQueryable.Core --version 10.0.8
#r "nuget: MockQueryable.Core, 10.0.8"
#:package MockQueryable.Core@10.0.8
#addin nuget:?package=MockQueryable.Core&version=10.0.8Install as a Cake Addin
#tool nuget:?package=MockQueryable.Core&version=10.0.8Install as a Cake Tool
Extensions for mocking Entity Framework Core async queries like ToListAsync, FirstOrDefaultAsync, and more using popular mocking libraries such as Moq, NSubstitute, and FakeItEasy — all without hitting the database.
❤️ If you really like the tool, please 👉 Support the project or ☕ Buy me a coffee.
| Package | Latest Version | Install via Package Manager |
|---|---|---|
| 👁 Download |
👁 Version |
Install-Package MockQueryable.Core |
| 👁 Download |
👁 Version |
Install-Package MockQueryable.EntityFrameworkCore |
| 👁 Download |
👁 Version |
Install-Package MockQueryable.Moq |
| 👁 Download |
👁 Version |
Install-Package MockQueryable.NSubstitute |
| 👁 Download |
👁 Version |
Install-Package MockQueryable.FakeItEasy |
👁 codecov
👁 build
👁 release
👁 License
👁 Stars
👁 Contributors
👁 Last Commit
👁 Commit Activity
👁 Open Issues
Avoid hitting the real database in unit tests when querying via IQueryable:
var query = _userRepository.GetQueryable();
await query.AnyAsync(x => ...);
await query.FirstOrDefaultAsync(x => ...);
await query.ToListAsync();
// etc.
var users = new List<UserEntity>
{
new UserEntity { LastName = "Smith", DateOfBirth = new DateTime(2012, 1, 20) },
// More test data...
};
var mock = users.BuildMock(); // for IQueryable
_userRepository.Setup(x => x.GetQueryable()).Returns(mock);
_userRepository.GetQueryable().Returns(mock);
A.CallTo(() => userRepository.GetQueryable()).Returns(mock);
DbSet<T>var mockDbSet = users.BuildMockDbSet();
// Moq
var repo = new TestDbSetRepository(mockDbSet.Object);
// NSubstitute / FakeItEasy
var repo = new TestDbSetRepository(mockDbSet);
FindAsyncmock.Setup(x => x.FindAsync(userId)).ReturnsAsync((object[] ids) =>
{
var id = (Guid)ids[0];
return users.FirstOrDefault(x => x.Id == id);
});
Build a mock with the custom for testing EF.Functions.Like
var mockDbSet = users.BuildMockDbSet<UserEntity, SampleLikeExpressionVisitor>();
You can even create your own extensions. Check the example here.
See the sample project for working examples.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 3 NuGet packages that depend on MockQueryable.Core:
| Package | Downloads |
|---|---|
|
MockQueryable.EntityFrameworkCore
Core package for MockQueryable extensions for mocking operations such ToListAsync, FirstOrDefaultAsync etc. When writing tests for your application it is often desirable to avoid hitting the database. The extension allows you to achieve this by creating a context – with behavior defined by your tests – that makes use of in-memory data. |
|
|
Matt.Paginated
Package Description |
|
|
Matt.ResultObject
Package Description |
Showing the top 2 popular GitHub repositories that depend on MockQueryable.Core:
| Repository | Stars |
|---|---|
|
CodeMazeBlog/CodeMazeGuides
The main repository for all the Code Maze guides
|
|
|
nuyonu/N-Tier-Architecture
This is a n-layer architecture based on Common web application architectures.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.8 | 195,212 | 5/16/2026 |
| 10.0.5 | 577,792 | 3/15/2026 |
| 10.0.2 | 422,572 | 1/29/2026 |
| 10.0.1 | 418,816 | 11/22/2025 |
| 10.0.0 | 4,684 | 11/22/2025 |
| 9.0.0 | 580,700 | 10/6/2025 |
| 8.0.1 | 627,805 | 10/6/2025 |
| 8.0.0 | 789,235 | 7/27/2025 |
| 7.0.4-beta | 224,806 | 9/24/2024 |
| 7.0.3 | 10,030,225 | 9/2/2024 |
| 7.0.2 | 370,641 | 8/20/2024 |
| 7.0.1 | 3,996,463 | 3/7/2024 |
| 7.0.0 | 6,468,824 | 11/21/2022 |
| 6.0.1 | 6,635,473 | 3/28/2022 |
| 6.0.0 | 401,322 | 3/24/2022 |
| 5.0.2 | 416,305 | 3/24/2022 |
| 5.0.1 | 3,722,832 | 5/25/2021 |
| 5.0.0 | 1,463,391 | 11/12/2020 |
| 5.0.0-preview.7 | 34,410 | 7/28/2020 |
| 3.1.3 | 2,826,424 | 5/19/2020 |
#128 Microsoft.EntityFrameworkCore and Microsoft.EntityFrameworkCore.Relational v 10.0.8 - supported
#123 NUnit from 4.5.1 to 4.6.0