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.
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.
// Install Autofac.Extras.Moq as a Cake Addin
#addin nuget:?package=Autofac.Extras.Moq&version=7.0.0

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

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. 
.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 (16)

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
CodeMazeBlog/CodeMazeGuides
The main repository for all the Code Maze guides
DevArchitecture/DevArchitecture
DevArchitecture Backend Project
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
Version Downloads Last updated
7.0.0 88,269 10/1/2024
6.1.1 1,393,019 7/26/2023
6.1.0 3,278,876 10/21/2021
6.0.0 2,090,726 10/2/2020
5.0.1 1,168,480 3/22/2020
5.0.0 91,840 2/25/2020
4.3.0 2,877,504 10/23/2018
4.2.0 840,931 10/2/2017
4.1.0 26,179 9/28/2017
4.1.0-rc5-246 23,354 1/30/2017
4.1.0-rc4-242 997 1/29/2017
4.1.0-rc3-231 24,890 7/13/2016
4.0.0 1,269,802 10/13/2015
3.1.0 98,693 6/8/2015
3.0.2 71,622 3/27/2014
3.0.1 9,398 9/23/2013
3.0.0 11,174 1/30/2013
3.0.0-beta2 1,292 12/23/2012
3.0.0-beta 1,563 11/1/2012