Autofac.Extras.Moq 7.0.0

Prefix Reserved
dotnet add package Autofac.Extras.Moq --version 7.0.0
                    
NuGet\Install-Package Autofac.Extras.Moq -Version 7.0.0
                    
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="Autofac.Extras.Moq" Version="7.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Autofac.Extras.Moq" Version="7.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Autofac.Extras.Moq" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Autofac.Extras.Moq --version 7.0.0
                    
#r "nuget: Autofac.Extras.Moq, 7.0.0"
                    
#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.
#addin nuget:?package=Autofac.Extras.Moq&version=7.0.0
                    
Install Autofac.Extras.Moq as a Cake Addin
#tool nuget:?package=Autofac.Extras.Moq&version=7.0.0
                    
Install Autofac.Extras.Moq as a Cake Tool

Autofac.Extras.Moq

Moq auto mocking integration for Autofac.

Build status codecov NuGet

Please file issues and pull requests for this package in this repository rather than in the Autofac core repo.

⚠️ LOOKING FOR AN OWNER! This package is largely in maintenance mode - if you'd like to help the community out and pull it out of maintenance mode, come drop us a line!

Quick Start

Given you have a system under test and a dependency:

public class SystemUnderTest
{
  public SystemUnderTest(IDependency dependency)
  {
  }
}

public interface IDependency
{
}

When writing your unit test, use the Autofac.Extras.Moq.AutoMock class to instantiate the system under test. Doing this will automatically inject a mock dependency into the constructor for you. At the time you create the AutoMock factory, you can specify default mock behavior:

  • AutoMock.GetLoose() - creates automatic mocks using loose mocking behavior.
  • AutoMock.GetStrict() - creates automatic mocks using strict mocking behavior.
  • AutoMock.GetFromRepository(repo) - creates mocks based on an existing configured repository.
[Test]
public void Test()
{
  using (var mock = AutoMock.GetLoose())
  {
    // The AutoMock class will inject a mock IDependency
    // into the SystemUnderTest constructor
    var sut = mock.Create<SystemUnderTest>();
  }
}

Get Help

Need help with Autofac? We have a documentation site as well as API documentation. We're ready to answer your questions on Stack Overflow or check out the discussion forum.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.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 is compatible. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (11)

Showing the top 5 NuGet packages that depend on Autofac.Extras.Moq:

Package Downloads
given-fixture

Simple test fixture pattern

Autofac.Extras.Moq.Xunit

A small wrapper over AutoMock to simplify writing tests for Xunit.

FluentFixture

Simple test fixture pattern

JRevolt.Injection.Testing

Unit Testing Support for JRevolt.Injection

xunit.spec

Specification based testing with xunit

GitHub repositories (15)

Showing the top 15 popular GitHub repositories that depend on Autofac.Extras.Moq:

Repository Stars
dotnet/yarp
A toolkit for developing high-performance HTTP reverse proxy applications.
smartstore/Smartstore
A modular, scalable and ultra-fast open-source all-in-one eCommerce platform built on ASP.NET Core 7
CodeMazeBlog/CodeMazeGuides
The main repository for all the Code Maze guides
chayxana/Restaurant-App
Restaurant App 🍔 is a sample open-source e-Commerce 🛒 application for ordering foods, powered by polyglot microservices architecture and cross-platform development including mobile and web
axle-h/Retro.Net
Retro hardware libraries in .NET Core with an Angular front end
Azure/Industrial-IoT
Azure Industrial IoT Platform
PlexRipper/PlexRipper
A cross-platform Plex media downloader that seamlessly adds media from other Plex servers to your own!
dotnet/systemweb-adapters
newbe36524/Newbe.Claptrap
This is a frameworks with reactive, event sourcing and Actor pattern as basic theories. On top of this, developers can create "distributed", "scale out", and "easy to test" application more simply. Claptrap and it`s Minions is on the way.
keremvaris/Sennedjem
Sennedjem CQRS (Command Query Responsibility Segregation) yaklaşımını benimseyen ve SOLID prensiplerini ve Clean Architecture yöntemlerini odaklayan bir yazılım geliştirme alt yapısıdır. RabbitMq, ElasticSearch vb araçlara entegre olmak konusunda çok yeteneklidir.
MattHoneycutt/SpecsFor
SpecsFor is a light-weight Behavior-Driven Development framework that focuses on ease of use for *developers* by minimizing testing friction.
phil-guo/ketchup
ketchup (番茄酱) 是一个基于dotnet core的微服务框架。
aykutalparslan/Ferrite
Experimental Telegram Server
pkuehnel/TeslaSolarCharger
A software to let your Tesla charge with solar energy ☀
hailstorm75/ModularDoc
Modular documentation generator for .NET libraries. Currently supporting Markdown only for GitHub, GitLab, and Bitbucket
Version Downloads Last updated
7.0.0 490,949 10/1/2024
6.1.1 1,822,148 7/26/2023
6.1.0 3,585,010 10/21/2021
6.0.0 2,241,003 10/2/2020
5.0.1 1,222,289 3/22/2020
5.0.0 101,962 2/25/2020
4.3.0 3,004,641 10/23/2018
4.2.0 857,141 10/2/2017
4.1.0 28,830 9/28/2017
4.1.0-rc5-246 23,536 1/30/2017
4.1.0-rc4-242 1,128 1/29/2017
4.1.0-rc3-231 25,065 7/13/2016
4.0.0 1,302,842 10/13/2015
3.1.0 104,647 6/8/2015
3.0.2 73,415 3/27/2014
3.0.1 9,792 9/23/2013
3.0.0 12,074 1/30/2013
3.0.0-beta2 1,429 12/23/2012
3.0.0-beta 1,708 11/1/2012