Moq.Analyzers 0.1.0-beta

This is a prerelease version of Moq.Analyzers.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Moq.Analyzers --version 0.1.0-beta
                    
NuGet\Install-Package Moq.Analyzers -Version 0.1.0-beta
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Moq.Analyzers" Version="0.1.0-beta">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Moq.Analyzers" Version="0.1.0-beta" />
                    
Directory.Packages.props
<PackageReference Include="Moq.Analyzers">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Moq.Analyzers --version 0.1.0-beta
                    
#r "nuget: Moq.Analyzers, 0.1.0-beta"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Moq.Analyzers&version=0.1.0-beta&prerelease
                    
Install Moq.Analyzers as a Cake Addin
#tool nuget:?package=Moq.Analyzers&version=0.1.0-beta&prerelease
                    
Install Moq.Analyzers as a Cake Tool

Moq.Analyzers

Moq.Analyzers is a Roslyn analyzer that helps to write unit tests using the popular and friend Moq library. Moq.Analyzers protects you from popular mistakes and warns you if something is wrong with your Moq configuration:

Detected issues

  • Moq1000 = Sealed classes cannot be mocked.
  • Moq1001 = Mocked interfaces cannot have constructor parameters.
  • Moq1002 = Parameters provided into mock do not match any existing constructors.
  • Moq1100 = Callback signature must match the signature of the mocked method.
  • Moq1101 = SetupGet/SetupSet should be used for properties, not for methods.
  • Moq1200 = Setup should be used only for overridable members.
  • Moq1201 = Setup of async methods should use .ReturnsAsync instance instead of .Result.
  • Moq1300 = Mock.As() should take interfaces.

How to install

Install "Moq.Analyzers" NuGet package into test projects using Moq.

Contributions are welcome!

Moq.Analyzers continues to evolve and add new features. Any help will be appreciated. You can report issues, develop new features, improve the documention, or do other cool stuff.

If you want to contribute to existing issues, check the help wanted or good first issue items in the backlog. If you have new ideas or want to complain about bugs, feel free to create a new issue.

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to set expectations for behavior in our communication. For more information, see the .NET Foundation's Contributor Convenant Code of Conduct

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Moq.Analyzers:

Package Downloads
Reo.Core.Testing

Package Description

Reo.Core.IntegrationTesting

Package Description

Reo.Core.Testing.31

Package Description

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on Moq.Analyzers:

Repository Stars
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
Richasy/Bili.Copilot
B站第三方 Windows 桌面客户端,使用 Windows App SDK 构建的原生应用
Richasy/Rodel.Agent
支持主流在线 AI 服务的应用
Version Downloads Last updated
0.3.0 111,398 1/21/2025
0.3.0-alpha-0001 104 1/17/2025
0.3.0-alpha 113 12/24/2024
0.2.0 48,324 10/20/2024
0.2.0-alpha 92 10/20/2024
0.1.2 93,066 8/28/2024
0.1.1 63,796 6/28/2024
0.1.0 49,301 6/4/2024
0.1.0-beta 102 6/4/2024
0.0.9 790,144 1/11/2022
0.0.8 735,573 8/11/2019
0.0.7 5,298 7/28/2019
0.0.6 1,048 7/28/2019
0.0.4.43043 55,106 11/26/2017
0.0.4.41458 2,985 11/26/2017
0.0.3.40797 2,939 11/26/2017
0.0.1.22865 3,471 11/26/2017