Skip to content

feat: migrate NSubstitute AndDoes to Mockolate Do with parameter rewrites#58

Merged
vbreuss merged 3 commits intomainfrom
topic/migrate-nsubstitute-do-with-parameters
May 1, 2026
Merged

feat: migrate NSubstitute AndDoes to Mockolate Do with parameter rewrites#58
vbreuss merged 3 commits intomainfrom
topic/migrate-nsubstitute-do-with-parameters

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented May 1, 2026

This pull request primarily standardizes the naming conventions for test methods across several test files and adds documentation for how CallInfo callbacks are migrated. The test method names have been updated to use PascalCase for readability and consistency. Additionally, the README.md now includes a section explaining how CallInfo callback lambdas are migrated from NSubstitute to Mockolate.

Documentation improvements:

  • Added a section to README.md describing how CallInfo callbacks are migrated, with examples and guidance for different usage patterns.

Test method naming standardization:

  • Updated all test method names in ArgumentMatcherTests.cs, CreationTests.cs, EventTests.cs, SequenceTests.cs, and SetupTests.cs to use PascalCase for improved consistency and readability.

@vbreuss vbreuss self-assigned this May 1, 2026
Copilot AI review requested due to automatic review settings May 1, 2026 19:54
@vbreuss vbreuss added the enhancement New feature or request label May 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

Test Results

  9 files  ± 0    9 suites  ±0   2m 59s ⏱️ +19s
263 tests +18  263 ✅ +18  0 💤 ±0  0 ❌ ±0 
789 runs  +54  789 ✅ +54  0 💤 ±0  0 ❌ ±0 

Results for commit 57dd3b2. ± Comparison against base commit ba74810.

This pull request removes 84 and adds 102 tests. Note that renamed tests count towards both.
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ ItIsAny_matchesAnyValue
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ ItIsInRange_inclusive_matchesBoundaries
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ ItIsNotNull_rejectsNull
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ ItIsRegex_matchesPattern
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ ItIs_predicate_matchesEvenAmounts
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ OutParameter_isSetByItIsOut
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ PlainValue_isUsedAsExactMatch
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ RefParameter_anyMatch_acceptsAnyRef
Mockolate.Migration.MoqPlayground.CreationTests ‑ ClassMockWithConstructorArgs_isCreatedWithThoseArgs
Mockolate.Migration.MoqPlayground.CreationTests ‑ DefaultLooseMock_returnsDefaultsForUnsetMembers
…
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ ItIsAny_MatchesAnyValue
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ ItIsInRange_Inclusive_MatchesBoundaries
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ ItIsNotNull_RejectsNull
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ ItIsRegex_MatchesPattern
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ ItIs_Predicate_MatchesEvenAmounts
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ OutParameter_IsSetByItIsOut
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ PlainValue_IsUsedAsExactMatch
Mockolate.Migration.MoqPlayground.ArgumentMatcherTests ‑ RefParameter_AnyMatch_AcceptsAnyRef
Mockolate.Migration.MoqPlayground.CreationTests ‑ ClassMockWithConstructorArgs_IsCreatedWithThoseArgs
Mockolate.Migration.MoqPlayground.CreationTests ‑ DefaultLooseMock_ReturnsDefaultsForUnsetMembers
…

♻️ This comment has been updated with latest results.

@vbreuss vbreuss enabled auto-merge (squash) May 1, 2026 19:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enhances the NSubstitute→Mockolate migration code fix to handle CallInfo-based callbacks by rewriting them into Mockolate-compatible Do(...) / Returns(...) typed-parameter (or parameterless) lambdas, and documents/tests the new behavior.

Changes:

  • Rewrite When(...).Do(call => ...), Returns(call => ...), and AndDoes(call => ...) callbacks by dropping unused CallInfo parameters or translating supported CallInfo argument accesses into typed lambda parameters.
  • Add a new analyzer/code-fix test suite covering supported/unsupported CallInfo rewrite cases (including TODO fallback cases).
  • Update README documentation and normalize playground test method names.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Tests/Mockolate.Migration.Tests/NSubstituteCodeFixProviderTests.WhenDoTests.cs Updates expected output to drop unused CallInfo lambda parameters (Do(() => ...)).
Tests/Mockolate.Migration.Tests/NSubstituteCodeFixProviderTests.CallInfoTests.cs New test coverage for CallInfo callback rewrite rules and TODO fallbacks.
Tests/Mockolate.Migration.Tests/NSubstituteCodeFixProviderTests.AndDoesTests.cs Updates expected output to drop unused CallInfo lambda parameters on migrated .Do(...).
Tests/Mockolate.Migration.NSubstitutePlayground/WhenDoTests.cs Renames test methods for consistent naming.
Tests/Mockolate.Migration.NSubstitutePlayground/UnsupportedFeatureTests.cs Renames tests and updates commentary around partial CallInfo support.
Tests/Mockolate.Migration.NSubstitutePlayground/SetupTests.cs Adds a runtime playground test demonstrating argument-dispatch via CallInfo in Returns.
Tests/Mockolate.Migration.NSubstitutePlayground/EventTests.cs Renames test methods for consistent naming.
Tests/Mockolate.Migration.NSubstitutePlayground/CreationTests.cs Renames test methods for consistent naming.
Tests/Mockolate.Migration.NSubstitutePlayground/ArgumentMatcherTests.cs Renames test methods for consistent naming.
Tests/Mockolate.Migration.MoqPlayground/UnsupportedFeatureTests.cs Renames test methods for consistent naming.
Tests/Mockolate.Migration.MoqPlayground/SetupTests.cs Renames test methods for consistent naming.
Tests/Mockolate.Migration.MoqPlayground/SequenceTests.cs Renames test methods for consistent naming.
Tests/Mockolate.Migration.MoqPlayground/EventTests.cs Renames test methods for consistent naming.
Tests/Mockolate.Migration.MoqPlayground/CreationTests.cs Renames test methods for consistent naming.
Tests/Mockolate.Migration.MoqPlayground/ArgumentMatcherTests.cs Renames test methods for consistent naming.
Source/Mockolate.Migration.Analyzers.CodeFixers/NSubstituteCodeFixProvider.cs Implements CallInfo callback rewriting + TODO injection and threads it through When/Do, Returns, and AndDoes.
README.md Documents CallInfo callback migration behavior and fallback rules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 1, 2026

@vbreuss vbreuss merged commit 7481f0c into main May 1, 2026
9 checks passed
@vbreuss vbreuss deleted the topic/migrate-nsubstitute-do-with-parameters branch May 1, 2026 20:25
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

This is addressed in release v0.5.0.

@github-actions github-actions Bot added the state: released The issue is released label May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants