Skip to main content

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

Total Downloads
105.2K
105,242
Published
Mar 20, 2023
Latest stable version

Install

.NET CLI
dotnet add package TransparentMoq --version 4.18.1.2-u20230320-164816-ci+50c23f8eca
Package Manager Console
Install-Package TransparentMoq -Version 4.18.1.2-u20230320-164816-ci+50c23f8eca
PackageReference
<PackageReference Include="TransparentMoq" Version="4.18.1.2-u20230320-164816-ci+50c23f8eca" />

Frameworks

.NETFramework4.6.2 .NETStandard2.0 .NETStandard2.1

Dependencies

Moq
.NETFramework4.6.2
[4.18.2, )
Moq
.NETStandard2.0
[4.18.2, )
Moq
.NETStandard2.1
[4.18.2, )

Adoption guide

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

This version is marked prerelease. Validate its API and upgrade path before production use.

Compatibility metadata lists 3 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.