![]() |
VOOZH | about |
dotnet add package Moq --version 4.20.69
NuGet\Install-Package Moq -Version 4.20.69
<PackageReference Include="Moq" Version="4.20.69" />
<PackageVersion Include="Moq" Version="4.20.69" />Directory.Packages.props
<PackageReference Include="Moq" />Project file
paket add Moq --version 4.20.69
#r "nuget: Moq, 4.20.69"
#:package Moq@4.20.69
#addin nuget:?package=Moq&version=4.20.69Install as a Cake Addin
#tool nuget:?package=Moq&version=4.20.69Install as a Cake Tool
The most popular and friendly mocking library for .NET
var mock = new Mock<ILoveThisLibrary>();
// WOW! No record/replay weirdness?! :)
mock.Setup(library => library.DownloadExists("2.0.0.0"))
.Returns(true);
// Use the Object property on the mock to get a reference to the object
// implementing ILoveThisLibrary, and then exercise it by calling
// methods on it
ILoveThisLibrary lovable = mock.Object;
bool download = lovable.DownloadExists("2.0.0.0");
// Verify that the given method was indeed called with the expected value at most once
mock.Verify(library => library.DownloadExists("2.0.0.0"), Times.AtMostOnce());
Moq also is the first and only library so far to provide Linq to Mocks, so that the same behavior above can be achieved much more succinctly:
ILoveThisLibrary lovable = Mock.Of<ILoveThisLibrary>(l =>
l.DownloadExists("2.0.0.0") == true);
// Exercise the instance returned by Mock.Of by calling methods on it...
bool download = lovable.DownloadExists("2.0.0.0");
// Simply assert the returned state:
Assert.True(download);
// If you want to go beyond state testing and want to
// verify the mock interaction instead...
Mock.Get(lovable).Verify(library => library.DownloadExists("2.0.0.0"));
You can think of Linq to Mocks as "from the universe of mocks, give me one whose behavior matches this expression".
Check out the Quickstart for more examples!
๐ Clarius Org
๐ C. Augusto Proiete
๐ Kirill Osenkov
๐ MFB Technologies, Inc.
๐ Stephen Shaw
๐ Torutek
๐ DRIVE.NET, Inc.
๐ David Kean
๐ alternate text is missing from this package README image
๐ Daniel Gnรคgi
๐ Ashley Medway
๐ Keith Pickford
๐ bitbonk
๐ Thomas Bolon
๐ Yurii Rashkovskii
๐ Kori Francis
๐ Zdenek Havlin
๐ Sean Killeen
๐ Toni Wenzel
๐ Giorgi Dalakishvili
๐ Kelly White
๐ Allan Ritchie
๐ Mike James
๐ Uno Platform
๐ Dan Siegel
๐ Reuben Swartz
๐ Jeremy Simmons
๐ Jacob Foshee
๐ alternate text is missing from this package README image
๐ Eric Johnson
๐ Norman Mackay
๐ Certify The Web
๐ Taylor Mansfield
๐ Mรฅrten Rรฅnge
๐ David Petric
๐ Rich Lee
๐ Danilo Dantas
๐ alternate text is missing from this package README image
๐ Gary Woodfine
๐ alternate text is missing from this package README image
๐ alternate text is missing from this package README image
๐ Steve Bilogan
๐ Ix Technologies B.V.
๐ New Relic
๐ Chris Johnstonโฎ
๐ David JENNI
๐ alternate text is missing from this package README image
๐ Jonathan
๐ Oleg Kyrylchuk
๐ Juan Blanco
๐ LosManos
๐ Mariusz Kogut
๐ Charley Wu
๐ alternate text is missing from this package README image
๐ Thomas Due
๐ Jakob Tikjรธb Andersen
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. 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. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Moq:
| Package | Downloads |
|---|---|
|
AutoFixture.AutoMoq
This extension turns AutoFixture into an Auto-Mocking Container. The mock instances are created by Moq. To use it, add the AutoMoqCustomization to your Fixture instance. Read more at http://blog.ploeh.dk/2010/08/19/AutoFixtureAsAnAutomockingContainer.aspx |
|
|
MockQueryable.Moq
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. |
|
|
Moq.AutoMock
An auto-mocking container that generates mocks using Moq |
|
|
Autofac.Extras.Moq
Autofac extension for automocking and creation of mock objects in Moq. |
|
|
Moq.EntityFrameworkCore
Library that provides methods that will help you with mocking Entity Framework Core. Easily mock DbSet and DbContext for unit testing with Moq. |
Showing the top 20 popular GitHub repositories that depend on Moq:
| Repository | Stars |
|---|---|
|
jellyfin/jellyfin
The Free Software Media System - Server Backend & API
|
|
|
DevToys-app/DevToys
A Swiss Army knife for developers.
|
|
|
AvaloniaUI/Avalonia
Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The future of .NET UI
|
|
|
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
|
|
|
BeyondDimension/SteamTools
๐ ใWatt Toolkitใๆฏไธไธชๅผๆบ่ทจๅนณๅฐ็ๅคๅ่ฝ Steam ๅทฅๅ
ท็ฎฑใ
|
|
|
dotnet/roslyn
The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
|
|
|
jasontaylordev/CleanArchitecture
Clean Architecture Solution Template for ASP.NET Core
|
|
|
QuantConnect/Lean
Lean Algorithmic Trading Engine by QuantConnect (Python, C#)
|
|
|
ppy/osu
rhythm is just a *click* away!
|
|
|
dotnet/runtime
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
|
|
|
Flow-Launcher/Flow.Launcher
:mag: Quick file search & app launcher for Windows with community-made plugins
|
|
|
Sonarr/Sonarr
Smart PVR for newsgroup and bittorrent users.
|
|
|
Radarr/Radarr
Movie organizer/manager for usenet and torrent users.
|
|
|
JosefNemec/Playnite
Video game library manager with support for wide range of 3rd party libraries and game emulation support, providing one unified interface for your games.
|
|
|
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
|
|
|
chocolatey/choco
Chocolatey - the package manager for Windows
|
|
|
memstechtips/Winhance
Application designed to optimize, customize and enhance your Windows experience.
|
|
|
JamesNK/Newtonsoft.Json
Json.NET is a popular high-performance JSON framework for .NET
|
|
|
tui-cs/Terminal.Gui
Cross Platform Terminal UI toolkit for .NET
|
|
|
MathewSachin/Captura
Capture Screen, Audio, Cursor, Mouse Clicks and Keystrokes
|
| Version | Downloads | Last Updated |
|---|---|---|
| 4.20.72 | 192,890,137 | 9/7/2024 |
| 4.20.70 | 108,842,485 | 11/28/2023 |
| 4.20.69 | 29,708,677 | 8/11/2023 |
| 4.18.4 | 118,535,436 | 12/30/2022 |
| 4.18.3 | 10,200,087 | 12/5/2022 |
| 4.18.2 | 52,421,692 | 8/2/2022 |
| 4.18.1 | 34,169,339 | 5/16/2022 |
| 4.18.0 | 2,245,574 | 5/11/2022 |
| 4.17.2 | 31,477,051 | 3/6/2022 |
| 4.17.1 | 2,788,221 | 2/26/2022 |
| 4.16.1 | 129,910,359 | 2/23/2021 |
| 4.16.0 | 20,902,812 | 1/16/2021 |
| 4.15.2 | 15,854,652 | 11/26/2020 |