Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

AutoMoq

> 编程语言
Open source

Auto mocking provider for Moq.

192 stars0 likes2 views
WebsiteGitHub

About

Auto mocking provider for Moq.

AutoMoq

AutoMoqer is an "auto-mocking" container that creates objects for you. Just tell it what class to create and it will create it.

But how?

It injects mocks as any undefined dependencies.

csharp
class NeatoRepository {
  public NeatoRepository(ISomething something){
    // ..
  }
}

var mocker = new AutoMoqer();

var neatoRepository = mocker.Create();

// but what about ISomething?

mocker.GetMock(); // I was injected as ISomething

But why?

Let's pretend you did not use AutoMoq and you changed your dependencies:

csharp

// I wrote this code in my tests...
var neatoRepository = new NeatoRepository(null);

// ... then I changed my class...
class NeatoRepository {
  public NeatoRepository(ISomething something, ISomethingElse somethingElse){
    // ..
  }
}

// NOW I HAVE TO FIX ALL OTHER REFERENCES TO GET A BUILD
var neatoRepository = new NeatoRepository(null);

If you used AutoMoq, this could would always compile:

csharp
var neatoRepository = mocker.Create();

Leaving you to just worry about how to change your logic, not your syntax.

Another Example

The dependencies injected into the class you are testing can be accessed before and/or after you call Create. Like so:

csharp

   var mocker = new AutoMoqer();

   mocker.GetMock()
      .Setup(x => x.GetData())
      .Returns("TEST DATA");

   var classToTest = mocker.Resolve();

   classToTest.DoSomething();

   mocker.GetMock()
      .Setup(x=>x.CallMe("TEST"), Times.Once());

That's It

It's a simple tool, but it can save a lot of headaches.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言