PosInformatique.Moq.Analyzers
1.4.0
Prefix Reserved
See the version list below for details.
dotnet add package PosInformatique.Moq.Analyzers --version 1.4.0
NuGet\Install-Package PosInformatique.Moq.Analyzers -Version 1.4.0
<PackageReference Include="PosInformatique.Moq.Analyzers" Version="1.4.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add PosInformatique.Moq.Analyzers --version 1.4.0
#r "nuget: PosInformatique.Moq.Analyzers, 1.4.0"
// Install PosInformatique.Moq.Analyzers as a Cake Addin #addin nuget:?package=PosInformatique.Moq.Analyzers&version=1.4.0 // Install PosInformatique.Moq.Analyzers as a Cake Tool #tool nuget:?package=PosInformatique.Moq.Analyzers&version=1.4.0
PosInformatique.Moq.Analyzers
PosInformatique.Moq.Analyzers is a library to verify syntax and code design when writing the unit tests using the Moq library.
Installing from NuGet
The PosInformatique.Moq.Analyzers
library is available directly on the
official website.
To download and install the library to your Visual Studio unit test projects use the following NuGet command line
Install-Package PosInformatique.Moq.Analyzers
The analyzer is automatically added and activated with their default severity levels.
Rules
This section describes the list of the rules analyzed by the library to improve code quality of the unit tests using the Moq library.
Design
Design rules used to make your unit tests more strongly strict.
Rule | Description |
---|---|
PosInfoMoq1000: Verify() and VerifyAll() methods should be called when instantiate a Mock<T> instances |
When instantiating a Mock<T> in the Arrange phase of an unit test, Verify() or VerifyAll() method should be called in the Assert phase to check the setup methods has been called. |
PosInfoMoq1001: The Mock<T> instance behavior should be defined to Strict mode |
When instantiating a Mock<T> instance, the MockBehavior of the Mock instance should be defined to Strict . |
Compilation
Compilation rules check some error during the compilation to be sure that the execution of the unit tests with Mock<T>
will not raise exceptions.
All the rules of this category should not be disabled (or changed their severity differently of Error).
Rule | Description |
---|---|
PosInfoMoq2000: The Returns() or ReturnsAsync() methods must be call for Strict mocks |
When a Mock<T> has been defined with the Strict behavior, the Returns() or ReturnsAsync() method must be called when setup a method to mock which returns a value. |
PosInfoMoq2001: The Setup() method must be used only on overridable members) |
The Setup() method must be applied only for overridable members. |
PosInfoMoq2002: Mock<T> class can be used only to mock non-sealed class |
The Mock<T> can mock only interfaces or non-sealed classes. |
PosInfoMoq2003: The Callback() delegate expression must match the signature of the mocked method |
The delegate in the argument of the Callback() method must match the signature of the mocked method. |
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.10.0 | 61 | 9/2/2024 |
1.10.0-rc.2 | 47 | 8/28/2024 |
1.10.0-rc.1 | 35 | 8/28/2024 |
1.9.3 | 115 | 8/19/2024 |
1.9.3-rc.2 | 44 | 8/16/2024 |
1.9.3-rc.1 | 43 | 8/16/2024 |
1.9.2 | 77 | 8/6/2024 |
1.9.2-rc.1 | 41 | 7/29/2024 |
1.9.1 | 92 | 7/17/2024 |
1.9.1-rc.3 | 39 | 7/13/2024 |
1.9.1-rc.2 | 38 | 7/11/2024 |
1.9.1-rc.1 | 28 | 7/11/2024 |
1.8.0 | 105 | 7/3/2024 |
1.7.0 | 84 | 6/28/2024 |
1.6.0 | 76 | 6/24/2024 |
1.5.0 | 92 | 6/10/2024 |
1.4.0 | 519 | 2/26/2024 |
1.3.0 | 318 | 12/5/2023 |
1.2.0 | 218 | 11/7/2023 |
1.1.0 | 158 | 11/7/2023 |
1.0.0 | 193 | 11/1/2023 |
1.4.0
- Reduce the dependency of Microsoft.CodeAnalysis.CSharp to the release 4.0.1.
1.3.0
- Add new rules:
- PosInfoMoq2003 rule to check the Callback() signature method (fixes #3).
- Fixes the PosInfoMoq2000 rule to check the call of the Returns()/ReturnsAsync() methods for the mocked properties for the mock with Strict behavior.
1.2.0
- Add new rules:
- PosInfoMoq2001: The Setup() method must be used only on overridable members.
- PosInfoMoq2002: Mock<T> class can be used only to mock non-sealed class.
1.1.0
- Add new rules:
- PosInfoMoq2000: The Returns() or ReturnsAsync() methods must be call for Strict mocks.
1.0.0
- Initial version with the followings rules:
- PosInfoMoq1000: Verify() and VerifyAll() methods should be called when instantiate a Mock<T> instances
- PosInfoMoq1001: The Mock<T> instance behavior should be defined to Strict mode.