TransparentMoq
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);
Install
dotnet add package TransparentMoq --version 4.20.70.1+e14df02c6b
Install-Package TransparentMoq -Version 4.20.70.1+e14df02c6b
<PackageReference Include="TransparentMoq" Version="4.20.70.1+e14df02c6b" />
Frameworks
Dependencies
Adoption guide
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Compatibility metadata lists 6 target frameworks; confirm the exact target used by your application.
How to read this guidance
Sources: published NuGet v3 registry metadata and explicit NuBrowse editorial guides. Refresh: package metadata is refreshed from NuGet when the page loads. Limit: this is not a security, legal or compatibility guarantee; validate the selected version in your project.
Useful next steps
Move from package metadata to a concrete selection or review workflow.