Skip to content

Simple "auto-mocking" container inspired by AutoMoq with less dependencies and compatible with .NET Core

License

Notifications You must be signed in to change notification settings

sgtHoloToaster/AutoMoqSlim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoMoqSlim

AutoMoqSlim is a simple "auto-mocking" container inspired by AutoMoq with fewer dependencies and compatible with .NET Core

What is it for?

Suppose you have a class with multiple dependencies

public ClassForTesting(IMockMe mockMe, INoNeedToMock noNeedToMock, ILogger logger)

But for your test you need to mock only one of them. In any case, in order to create an instance of the target class you need to create stubs for all of its dependencies manually

var mock = new Mock<IMockMe>();
mock.Setup(/*setup*/)
// continue to setup your mock
var stub1 = new Mock<INoNeedToMock>();
var stub2 = new Mock<ILogger>();
var target = new ClassForTesting(mock.Object, stub1.Object, stub2.Object);

And the number of unused dependencies may be much higher This package makes it a little bit easier. In this case it would be something like

var autoMoqer = new AutoMoqSlim();
autoMoqer.GetMock<IMockMe>()
 .Setup(/*setup*/)
// continue to setup your mock
var target = autoMoqer.Create<ClassForTesting>();

Installation

via Package Manager

PM> Install-Package AutoMoqSlim

via dotnet CLI

> dotnet add package AutoMoqSlim

About

Simple "auto-mocking" container inspired by AutoMoq with less dependencies and compatible with .NET Core

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages