{"id":22070382,"url":"https://github.com/posinformatique/posinformatique.moq.analyzers","last_synced_at":"2025-07-26T08:38:07.727Z","repository":{"id":204775477,"uuid":"712160869","full_name":"PosInformatique/PosInformatique.Moq.Analyzers","owner":"PosInformatique","description":"PosInformatique.Moq.Analyzers is a library to verify syntax and code design when writing the unit tests using the Moq library.","archived":false,"fork":false,"pushed_at":"2024-10-28T03:23:54.000Z","size":197,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-09T23:48:02.434Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PosInformatique.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-30T23:11:58.000Z","updated_at":"2024-10-28T08:43:56.000Z","dependencies_parsed_at":"2024-10-22T22:50:25.684Z","dependency_job_id":"4d080f52-13d3-4014-a109-7f7748f607a4","html_url":"https://github.com/PosInformatique/PosInformatique.Moq.Analyzers","commit_stats":null,"previous_names":["posinformatique/posinformatique.moq.analyzers"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/PosInformatique/PosInformatique.Moq.Analyzers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PosInformatique%2FPosInformatique.Moq.Analyzers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PosInformatique%2FPosInformatique.Moq.Analyzers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PosInformatique%2FPosInformatique.Moq.Analyzers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PosInformatique%2FPosInformatique.Moq.Analyzers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PosInformatique","download_url":"https://codeload.github.com/PosInformatique/PosInformatique.Moq.Analyzers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PosInformatique%2FPosInformatique.Moq.Analyzers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266815221,"owners_count":23988563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-30T20:16:13.284Z","updated_at":"2025-07-24T08:35:51.492Z","avatar_url":"https://github.com/PosInformatique.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PosInformatique.Moq.Analyzers\nPosInformatique.Moq.Analyzers is a library to verify syntax and code design when writing the unit tests using the [Moq](https://github.com/devlooped/moq) library.\n\n## Installing from NuGet\nThe [PosInformatique.Moq.Analyzers](https://www.nuget.org/packages/PosInformatique.FluentAssertions.Json/)\nlibrary is available directly on the\n[![Nuget](https://img.shields.io/nuget/v/PosInformatique.Moq.Analyzers)](https://www.nuget.org/packages/PosInformatique.Moq.Analyzers/)\nofficial website.\n\nTo download and install the library to your Visual Studio unit test projects use the following NuGet command line \n\n```\nInstall-Package PosInformatique.Moq.Analyzers\n```\n\nThe analyzer is automatically added and activated with their default severity levels.\n\n## Rules\n\nThis section describes the list of the rules analyzed by the library to improve code quality of the unit tests using\nthe [Moq](https://github.com/devlooped/moq) library.\n\n### Design\n\nDesign rules used to make your unit tests more strongly strict.\n\n| Rule | Description |\n| - | - |\n| [PosInfoMoq1000: `VerifyAll()` methods should be called when instantiate a `Mock\u003cT\u003e` instances](docs/Design/PosInfoMoq1000.md) | When instantiating a `Mock\u003cT\u003e` in the *Arrange* phase of an unit test, `VerifyAll()` method should be called in the *Assert* phase to check the setup methods has been called. |\n| [PosInfoMoq1001: The mocked instances behaviors should be defined to `Strict` mode](docs/Design/PosInfoMoq1001.md) | When instantiating a `Mock\u003cT\u003e` instance, the `MockBehavior` of the `Mock` instance should be defined to `Strict`. |\n| [PosInfoMoq1002: `Verify()` methods should be called when `Verifiable()` has been setup](docs/Design/PosInfoMoq1002.md) | When a mocked member has been setup with the `Verifiable()` method, the `Verify()` method must be called at the end of the unit test. |\n| [PosInfoMoq1003: The `Callback()` method should be used to check the parameters when mocking a method with `It.IsAny\u003cT\u003e()` arguments](docs/Design/PosInfoMoq1003.md) | When a mocked method contains a `It.IsAny\u003cT\u003e()` argument, the related parameter should be checked in the `Callback()` method. |\n| [PosInfoMoq1004: The `Callback()` parameter should not be ignored if it has been setup as an `It.IsAny\u003cT\u003e()` argument](docs/Design/PosInfoMoq1004.md) | When a mocked method contains a `It.IsAny\u003cT\u003e()` argument, the related parameter should not be ignored in the `Callback()` method. |\n| [PosInfoMoq1005: Defines the generic argument of the `SetupSet()` method with the type of the mocked property](docs/Design/PosInfoMoq1005.md) | When mocking the setter of a property, use the `SetupSet\u003cTProperty\u003e()` method version. |\n\n### Compilation\n\nCompilation rules check some error during the compilation to be sure that the execution of the unit tests with `Mock\u003cT\u003e` will not raise exceptions.\nAll the rules of this category should not be disabled (or changed their severity differently of **Error**).\n\n| Rule | Description |\n| - | - |\n| [PosInfoMoq2000: The `Returns()` or `ReturnsAsync()` methods must be call for Strict mocks](docs/Compilation/PosInfoMoq2000.md) | When a `Mock\u003cT\u003e` 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. |\n| [PosInfoMoq2001: The `Setup()`/`SetupSet()` method must be used only on overridable members](docs/Compilation/PosInfoMoq2001.md)) | The `Setup()` method must be applied only for overridable members. |\n| [PosInfoMoq2002: `Mock\u003cT\u003e` class can be used only to mock non-sealed class](docs/Compilation/PosInfoMoq2002.md) | The `Mock\u003cT\u003e` class can mock only interfaces or non-`sealed` classes. |\n| [PosInfoMoq2003: The `Callback()` delegate expression must match the signature of the mocked method](docs/Compilation/PosInfoMoq2003.md) | The delegate in the argument of the `Callback()` method must match the signature of the mocked method. |\n| [PosInfoMoq2004: Constructor arguments cannot be passed for interface mocks](docs/Compilation/PosInfoMoq2004.md) | No arguments can be passed to a mocked interface. |\n| [PosInfoMoq2005: Constructor arguments must match the constructors of the mocked class](docs/Compilation/PosInfoMoq2005.md) | When instantiating a `Mock\u003cT\u003e`, the parameters must match one of the constructors of the mocked type.  |\n| [PosInfoMoq2006: The Protected().Setup() method must be use with overridable protected or internal methods](docs/Compilation/PosInfoMoq2006.md) | When using the `Protected().Setup()` configuration, the method mocked must be overridable and protected or internal. |\n| [PosInfoMoq2007: The `As\u003cT\u003e()` method can be used only with interfaces.](docs/Compilation/PosInfoMoq2007.md) | The `As\u003cT\u003e()` can only be use with the interfaces. |\n| [PosInfoMoq2008: The `Verify()` method must be used only on overridable members](docs/Compilation/PosInfoMoq2008.md)) | The `Verify()` method must be applied only for overridable members. |\n| [PosInfoMoq2009: `Mock.Of\u003cT\u003e` method must be used only to mock non-sealed class](docs/Compilation/PosInfoMoq2009.md) | The `Mock.Of\u003cT\u003e` method can mock only interfaces or non-`sealed` classes |\n| [PosInfoMoq2010: `Mock.Of\u003cT\u003e` method must be used only with types that contains parameterless contructor](docs/Compilation/PosInfoMoq2010.md) | The `Mock.Of\u003cT\u003e` method requires a non-private parameterless contructor |\n| [PosInfoMoq2011: Constructor of the mocked class must be accessible.](docs/Compilation/PosInfoMoq2011.md) | The constructor of the instantiate mocked class must non-private. |\n| [PosInfoMoq2012: The delegate in the argument of the `Returns()` method must return a value with same type of the mocked method.](docs/Compilation/PosInfoMoq2012.md) | The lambda expression, anonymous method or method in the argument of the `Returns()` must return return a value of the same type as the mocked method or property. |\n| [PosInfoMoq2013: The delegate in the argument of the `Returns()`/`ReturnsAsync()` method must have the same parameter types of the mocked method/property.](docs/Compilation/PosInfoMoq2013.md) | The lambda expression, anonymous method or method in the argument of the `Returns()`/`ReturnsAsync()` must have the same arguments type of the mocked method or property. |\n| [PosInfoMoq2014: The `Callback()` delegate expression must not return a value.](docs/Compilation/PosInfoMoq2014.md) | The `Callback()` delegate expression must not return a value. |\n| [PosInfoMoq2015: The `Protected().Setup()` method must match the return type of the mocked method](docs/Compilation/PosInfoMoq2015.md) | The method setup with `Protected().Setup()` must match the return type of the mocked method. |\n| [PosInfoMoq2016: `Mock\u003cT\u003e` constructor with factory lambda expression can be used only with classes.](docs/Compilation/PosInfoMoq2016.md) | The factory lambda expression used in `Mock\u003cT\u003e` instantiation must used only for the classes. |\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposinformatique%2Fposinformatique.moq.analyzers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposinformatique%2Fposinformatique.moq.analyzers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposinformatique%2Fposinformatique.moq.analyzers/lists"}