Refactor command handler tests to use IGitClient substitutes instead of TestGitRepositoryBuilder#334
Merged
geofflamrock merged 5 commits intomainfrom Aug 21, 2025
Conversation
Copilot
AI
changed the title
[WIP] Refactor all unit tests for **command handlers** to use a substitute instead of the test Git repo builder, except for the following test classes which already have in-progress PRs: NewStackCommandHandlerTests, StackSwitchCommandHandlerTests, DeleteStac...
Refactor command handler tests to use IGitClient substitutes instead of TestGitRepositoryBuilder
Aug 20, 2025
Owner
There was a problem hiding this comment.
@copilot convert the rest of the tests in the file to use the substitute
Contributor
Author
There was a problem hiding this comment.
Completed the conversion of all remaining tests in CleanupStackCommandHandlerTests.cs to use IGitClient substitutes instead of TestGitRepositoryBuilder. All 9 tests have been successfully converted and are passing. The changes follow the same pattern as the other converted test files, using GitBranchStatus objects to mock branch states and verifying behavior through substitute method calls rather than actual repository state. (870f5b4)
Co-authored-by: geofflamrock <2915931+geofflamrock@users.noreply.github.com>
Co-authored-by: geofflamrock <2915931+geofflamrock@users.noreply.github.com>
Co-authored-by: geofflamrock <2915931+geofflamrock@users.noreply.github.com>
…ubstitutes Co-authored-by: geofflamrock <2915931+geofflamrock@users.noreply.github.com>
870f5b4 to
abd7a37
Compare
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 PR refactors command handler unit tests to use
IGitClientsubstitutes instead ofTestGitRepositoryBuilderfor better test isolation and performance. The changes eliminate dependencies on actual git repositories in unit tests, making them faster and more reliable.Changes Made
Converted Test Classes
TestGitRepositoryBuildertoIGitClientsubstituteTestGitRepositoryBuildertoIGitClientsubstituteTestGitRepositoryBuildertoIGitClientsubstituteTechnical Implementation
The conversion follows a consistent pattern:
Before:
After:
Test Verification
Tests now verify behavior through substitute method calls rather than checking repository state:
Excluded Test Classes
The following test classes were excluded as they have in-progress PRs:
NewStackCommandHandlerTestsStackSwitchCommandHandlerTestsDeleteStackCommandHandlerTestsTest Classes Already Using Substitutes
These classes were already properly converted and required no changes:
UpdateStackCommandHandlerTestsPullStackCommandHandlerTestsPushStackCommandHandlerTestsSyncStackCommandHandlerTestsBenefits
All converted tests pass successfully and maintain the same test coverage as the original implementations.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.