Info
Version: | 4.20.70.1+e14df02c6b |
Author(s): | Kim Hugener-Ohlsen |
Last Update: | Tuesday, March 12, 2024 |
.NET Fiddle: | Create the first Fiddle |
Project Url: | https://github.com/sundews/TransparentMoq |
NuGet Url: | https://www.nuget.org/packages/TransparentMoq |
Install
Install-Package TransparentMoq
dotnet add package TransparentMoq
paket add TransparentMoq
TransparentMoq Download (Unzip the "nupkg" after downloading)
Dependencies
Tags
TransparentMoq allows to use Moq without having to store mocks in Mock<T> variables, instead a T variable can be used.
This also removes the need to pass mocks with ".Object" everywhere as they can be passed directly.
The library provides extension methods for most (if not all) of Moq's methods, so they can be called directly on the T variable.
Examples:
Instead of
private Mock<IFileSystem> fileSystem = new Mock<IFileSystem>();
Write
private IFileSystem fileSystem = New.Mock<IFileSystem>();
Instead of
MethodThatTakesFileSystem(fileSystem.Object);
write
MethodThatTakesFileSystem(fileSystem);
To arrange a mock everything remains the same:
fileSystem.Setup(x => x.Exists(It.IsAny<string>())).Returns(true);.