Autofac.Extras.Moq 6.1.1

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Autofac.Extras.Moq --version 6.1.1
NuGet\Install-Package Autofac.Extras.Moq -Version 6.1.1
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="6.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Autofac.Extras.Moq --version 6.1.1
#r "nuget: Autofac.Extras.Moq, 6.1.1"
#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.
// Install Autofac.Extras.Moq as a Cake Addin
#addin nuget:?package=Autofac.Extras.Moq&version=6.1.1

// Install Autofac.Extras.Moq as a Cake Tool
#tool nuget:?package=Autofac.Extras.Moq&version=6.1.1

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.

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 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 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

DNC.Testing

DNC.Testing

GitHub repositories (15)

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

Repository Stars
microsoft/reverse-proxy
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
dotnet/upgrade-assistant
A tool to assist developers in upgrading .NET Framework applications to .NET 6 and beyond
CodeMazeBlog/CodeMazeGuides
The main repository for all the Code Maze guides
DevArchitecture/DevArchitecture
DevArchitecture Backend Project
Version Downloads Last updated
6.1.1 683,748 7/26/2023
6.1.0 2,853,006 10/21/2021
6.0.0 1,921,101 10/2/2020
5.0.1 1,080,744 3/22/2020
5.0.0 82,046 2/25/2020
4.3.0 2,714,511 10/23/2018
4.2.0 814,983 10/2/2017
4.1.0 24,125 9/28/2017
4.1.0-rc5-246 23,148 1/30/2017
4.1.0-rc4-242 927 1/29/2017
4.1.0-rc3-231 24,709 7/13/2016
4.0.0 1,226,545 10/13/2015
3.1.0 93,558 6/8/2015
3.0.2 70,108 3/27/2014
3.0.1 8,995 9/23/2013
3.0.0 10,211 1/30/2013
3.0.0-beta2 1,217 12/23/2012
3.0.0-beta 1,483 11/1/2012