feat: migrate NSubstitute setup calls and Arg matchers#43
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds NSubstitute setup/matcher migration behavior to the NSubstitute code fix, along with new tests verifying the rewritten setup calls and translated Arg.* matchers.
Changes:
- Extend
NSubstituteCodeFixProviderto also rewrite NSubstitute setup/configuration call receivers to.<mock>.Mock.Setup.<member>(...)and translateArg.Any/Arg.IstoIt.*. - Add a new
SetupTeststest suite covering method/property setup rewrites and matcher translations. - Convert
NSubstituteCodeFixProviderTeststo a partial class to split test suites across files.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| Tests/Mockolate.Migration.Tests/NSubstituteCodeFixProviderTests.SetupTests.cs | New tests validating setup/matcher rewrites for NSubstitute migrations. |
| Tests/Mockolate.Migration.Tests/NSubstituteCodeFixProviderTests.CreationTests.cs | Make test container class partial to share across new test file. |
| Source/Mockolate.Migration.Analyzers.CodeFixers/NSubstituteCodeFixProvider.cs | Implement setup receiver rewriting and Arg.* matcher translation during creation-call migration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
This is addressed in release v0.5.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This pull request significantly enhances the NSubstitute-to-Mockolate migration code fix provider by adding support for rewriting NSubstitute setup/configuration calls and their argument matchers, along with comprehensive tests for these scenarios. The changes introduce logic to identify and transform NSubstitute's setup methods (like
Returns,Throws, etc.) and argument matchers (likeArg.Any,Arg.Is) into their Mockolate equivalents.The most important changes include:
Core migration logic improvements
Returns,Throws) and rewrite them to Mockolate'sMock.Setuppattern inNSubstituteCodeFixProvider. This includes handling both method and property setups.Arg.Any,Arg.Is, etc.) to the corresponding MockolateItmatchers (It.IsAny,It.Is,It.Satisfies). This ensures argument matching semantics are preserved during migration.Test coverage
SetupTestsinNSubstituteCodeFixProviderTeststo verify the correct rewriting of various NSubstitute setup patterns and argument matchers to Mockolate equivalents. These tests cover method setups, property setups, exception setups, and multiple argument matchers.Code quality and maintainability
usingdirectives for collections to support new logic.