TransparentMoq NuGet Package

With inspiration taken from mocking frameworks like NSubstitute, FakeItEasy and JustMock this package adds some of the syntactic advantages of these frameworks to Moq.

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);.




Got any TransparentMoq Question?





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)

.NETFramework 4.5
  • Moq(>= 4.16.0)
.NETStandard 2.0
  • Moq(>= 4.16.0)
netstandard2.1
  • Moq(>= 4.16.0)


Tags



STATS

must-have-score

2.5

avg-downloads-per-day

22

days-since-last-release

42