Moq.AutoMock
3.6.0-ci0539
See the version list below for details.
dotnet add package Moq.AutoMock --version 3.6.0-ci0539
NuGet\Install-Package Moq.AutoMock -Version 3.6.0-ci0539
<PackageReference Include="Moq.AutoMock" Version="3.6.0-ci0539" />
paket add Moq.AutoMock --version 3.6.0-ci0539
#r "nuget: Moq.AutoMock, 3.6.0-ci0539"
// Install Moq.AutoMock as a Cake Addin #addin nuget:?package=Moq.AutoMock&version=3.6.0-ci0539&prerelease // Install Moq.AutoMock as a Cake Tool #tool nuget:?package=Moq.AutoMock&version=3.6.0-ci0539&prerelease
Moq.AutoMock
An automocking container for Moq. Use this if you're invested in your IoC container and want to decouple your unit tests from changes to their constructor arguments.
Usage
Simplest usage is to build an instance that you can unit test.
var mocker = new AutoMocker();
var car = mocker.CreateInstance<Car>();
car.DriveTrain.ShouldNotBeNull();
car.DriveTrain.ShouldImplement<IDriveTrain>();
Mock<IDriveTrain> mock = Mock.Get(car.DriveTrain);
If you have a special instance that you need to use, you can register it
with .Use(...)
. This is very similar to registrations in a regular IoC
container (i.e. For<IService>().Use(x)
in StructureMap).
var mocker = new AutoMocker();
mocker.Use<IDriveTrain>(new DriveTrain());
// OR, setup a Mock
mocker.Use<IDriveTrain>(x => x.Shaft.Length == 5);
var car = mocker.CreateInstance<Car>();
Extracting Mocks
At some point you might need to get to a mock that was auto-generated. For
this, use the .Get<>()
or .GetMock<>()
methods.
var mocker = new AutoMocker();
// Let's say you have a setup that needs verifying
mocker.Use<IDriveTrain>(x => x.Accelerate(42) == true);
var car = mocker.CreateInstance<Car>();
car.Accelerate(42);
// Then extract & verify
var driveTrainMock = mocker.GetMock<IDriveTrain>();
driveTrainMock.VerifyAll();
Alternately, there's an even faster way to verify all mocks in the container:
var mocker = new AutoMocker();
mocker.Use<IDriveTrain>(x => x.Accelerate(42) == true);
var car = mocker.CreateInstance<Car>();
car.Accelerate(42);
// This method verifies all mocks in the container
mocker.VerifyAll();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Moq (>= 4.20.70)
- NonBlocking (>= 2.1.2)
NuGet packages (30)
Showing the top 5 NuGet packages that depend on Moq.AutoMock:
Package | Downloads |
---|---|
Reo.Core.Testing
Package Description |
|
Reo.Core.IntegrationTesting
Package Description |
|
Relay.Core.Plugins.NUnit
Plugins available for the Core framework |
|
Relay.Web.Testing
A web testing framework built for .NET Core |
|
Relay.Microservices.Testing
A microservice testing framework built for .NET Core |
GitHub repositories (21)
Showing the top 5 popular GitHub repositories that depend on Moq.AutoMock:
Repository | Stars |
---|---|
Ombi-app/Ombi
Want a Movie or TV Show on Plex/Emby/Jellyfin? Use Ombi!
|
|
dotnet/extensions
This repository contains a suite of libraries that provide facilities commonly needed when creating production-ready applications.
|
|
matthewrenze/clean-architecture-demo
A sample app for my online course "Clean Architecture: Patterns, Practices, and Principles" in .NET Framework 4.8
|
|
colinin/abp-next-admin
这是基于vue-vben-admin 模板适用于abp vNext的前端管理项目
|
|
vknet/vk
Vkontakte API for .NET
|
Version | Downloads | Last updated |
---|---|---|
3.6.0-ci0596 | 14,752 | 5/24/2024 |
3.6.0-ci0594 | 134 | 5/24/2024 |
3.6.0-ci0592 | 2,348 | 5/14/2024 |
3.6.0-ci0590 | 1,303 | 5/13/2024 |
3.6.0-ci0546 | 8,602 | 2/8/2024 |
3.6.0-ci0544 | 221 | 2/8/2024 |
3.6.0-ci0539 | 5,605 | 2/3/2024 |
3.6.0-ci0532 | 567 | 2/2/2024 |
3.5.0 | 4,995,341 | 1/4/2023 |
3.5.0-ci0332 | 614 | 1/4/2023 |
3.5.0-ci0331 | 659 | 1/4/2023 |
3.5.0-ci0287 | 20,088 | 10/10/2022 |
3.5.0-ci0285 | 1,939 | 10/3/2022 |
3.4.0 | 2,323,033 | 6/1/2022 |
3.4.0-ci0283 | 636 | 10/3/2022 |
3.4.0-ci0280 | 620 | 10/3/2022 |
3.4.0-ci0278 | 594 | 10/3/2022 |
3.4.0-ci0274 | 639 | 10/3/2022 |
3.4.0-ci0270 | 635 | 10/3/2022 |
3.4.0-ci0265 | 618 | 10/3/2022 |
3.4.0-ci0259 | 574 | 10/3/2022 |
3.4.0-ci0252 | 666 | 5/31/2022 |
3.3.1-ci0247 | 2,977 | 5/3/2022 |
3.3.1-ci0245 | 633 | 5/3/2022 |
3.3.1-ci0242 | 2,698 | 4/25/2022 |
3.3.0 | 912,778 | 2/23/2022 |
3.3.0-ci0240 | 763 | 4/25/2022 |
3.3.0-ci0221 | 1,144 | 2/21/2022 |
3.2.0 | 332,440 | 2/4/2022 |
3.2.0-ci0219 | 653 | 2/21/2022 |
3.2.0-ci0217 | 600 | 2/21/2022 |
3.2.0-ci0214 | 664 | 2/21/2022 |
3.2.0-ci0207 | 14,203 | 12/14/2021 |
3.2.0-ci0205 | 3,705 | 12/14/2021 |
3.1.0 | 772,757 | 10/29/2021 |
3.0.0 | 1,018,601 | 6/28/2021 |
3.0.0-ci0203 | 710 | 12/6/2021 |
3.0.0-ci0198 | 740 | 10/25/2021 |
3.0.0-ci0195 | 753 | 10/25/2021 |
3.0.0-ci0192 | 703 | 9/18/2021 |
3.0.0-ci0183 | 701 | 9/1/2021 |
3.0.0-ci0177 | 775 | 6/25/2021 |
3.0.0-ci0170 | 2,891 | 5/12/2021 |
3.0.0-ci0168 | 2,972 | 4/22/2021 |
3.0.0-ci0164 | 743 | 4/20/2021 |
3.0.0-ci0155 | 2,593 | 4/13/2021 |
3.0.0-ci0146 | 50,611 | 1/22/2021 |
3.0.0-ci0145 | 1,518 | 1/16/2021 |
2.3.0 | 1,528,751 | 12/15/2020 |
2.3.0-ci0136 | 839 | 12/15/2020 |
2.2.0.124 | 147,500 | 12/8/2020 |
2.2.0.123-ci | 870 | 12/8/2020 |
2.2.0.120-ci | 37,140 | 11/24/2020 |
2.2.0.115-ci | 841 | 11/23/2020 |
2.2.0.113-ci | 810 | 11/23/2020 |
2.1.0.104-ci | 875 | 11/23/2020 |
2.1.0.99-ci | 859 | 11/23/2020 |
2.1.0 | 697,533 | 9/9/2020 |
2.1.0-ci0019 | 882 | 9/9/2020 |
2.0.1 | 635,663 | 5/24/2020 |
2.0.1-ci0017 | 985 | 5/24/2020 |
2.0.0 | 192,257 | 4/6/2020 |
2.0.0-ci0015 | 943 | 5/5/2020 |
2.0.0-ci0014 | 899 | 5/5/2020 |
2.0.0-ci0012 | 943 | 4/6/2020 |
2.0.0-ci0011 | 961 | 4/6/2020 |
1.2.0.131-pre | 394,754 | 2/5/2020 |
1.2.0.128-pre | 955 | 2/5/2020 |
1.2.0.127-pre | 976 | 2/5/2020 |
1.2.0.122-pre | 114,959 | 5/17/2019 |
1.2.0.120 | 1,905,966 | 12/6/2018 |
1.2.0.118-pre | 1,176 | 12/6/2018 |
1.2.0.116-pre | 1,200 | 12/6/2018 |
1.2.0.113-pre | 4,849 | 8/1/2018 |
1.2.0.111 | 179,470 | 7/25/2018 |
1.2.0.109-pre | 1,319 | 7/25/2018 |
1.1.0.107-pre | 1,280 | 7/25/2018 |
1.1.0.105-pre | 1,376 | 7/25/2018 |
1.1.0.104-pre | 1,478 | 7/25/2018 |
1.1.0.96 | 23,599 | 6/8/2018 |
1.1.0.94-pre | 1,446 | 6/8/2018 |
1.1.0.92-pre | 1,467 | 6/8/2018 |
1.1.0.85-pre | 1,580 | 6/7/2018 |
1.1.0.68-pre | 1,451 | 6/4/2018 |
1.0.60 | 139,009 | 5/31/2018 |
1.0.56-pre | 1,438 | 5/31/2018 |
1.0.52-pre | 1,493 | 5/31/2018 |
1.0.48-pre | 1,482 | 5/31/2018 |
1.0.44-pre | 1,472 | 5/31/2018 |
1.0.41-pre | 1,509 | 5/30/2018 |
1.0.38-pre | 1,509 | 5/30/2018 |
1.0.35-pre | 1,513 | 5/30/2018 |
1.0.32-pre | 1,491 | 5/30/2018 |
0.4.0 | 672,160 | 9/7/2015 |
0.3.2.1 | 122,891 | 12/27/2012 |
0.3.2 | 2,226 | 8/23/2012 |
0.3.1 | 1,940 | 8/23/2012 |
0.3.0 | 4,041 | 8/23/2012 |
0.2.2 | 3,164 | 7/18/2012 |
0.2.1 | 2,032 | 7/18/2012 |
0.2.0 | 1,969 | 7/18/2012 |
0.1.0 | 19,733 | 7/18/2012 |