DI Refactor: Azure.Mcp.Tools.LoadTesting#2062
Merged
alzimmermsft merged 3 commits intomainfrom Mar 17, 2026
Merged
Conversation
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [mcp-158] Refactor Azure.Mcp.Tools.LoadTesting for dependency injection
DI Refactor: Azure.Mcp.Tools.LoadTesting
Mar 16, 2026
Remove unnecessary changelog
conniey
approved these changes
Mar 17, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Azure.Mcp.Tools.LoadTesting command implementations to use constructor-injected ILoadTestingService rather than resolving it from CommandContext during ExecuteAsync, aligning LoadTesting with the DI pattern referenced in #158.
Changes:
- Updated LoadTesting commands to accept
ILoadTestingServicevia constructor injection and to call the injected instance insideExecuteAsync. - Updated unit tests to construct commands with a mocked
ILoadTestingServicedirectly instead of registering it in aServiceCollection.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.LoadTesting/src/Commands/LoadTestRun/TestRunGetCommand.cs | Switches from context.GetService<ILoadTestingService>() to constructor-injected service. |
| tools/Azure.Mcp.Tools.LoadTesting/src/Commands/LoadTestRun/TestRunCreateOrUpdateCommand.cs | Same DI refactor for create/update test run flow. |
| tools/Azure.Mcp.Tools.LoadTesting/src/Commands/LoadTestResource/TestResourceListCommand.cs | Same DI refactor for listing load test resources. |
| tools/Azure.Mcp.Tools.LoadTesting/src/Commands/LoadTestResource/TestResourceCreateCommand.cs | Same DI refactor for creating load test resources. |
| tools/Azure.Mcp.Tools.LoadTesting/src/Commands/LoadTest/TestGetCommand.cs | Same DI refactor for getting a test definition. |
| tools/Azure.Mcp.Tools.LoadTesting/src/Commands/LoadTest/TestCreateCommand.cs | Same DI refactor for creating a test definition. |
| tools/Azure.Mcp.Tools.LoadTesting/tests/Azure.Mcp.Tools.LoadTesting.UnitTests/TestRunGetCommandTests.cs | Updates tests to pass mocked service directly to command constructor. |
| tools/Azure.Mcp.Tools.LoadTesting/tests/Azure.Mcp.Tools.LoadTesting.UnitTests/TestRunCreateOrUpdateCommandTests.cs | Updates tests to pass mocked service directly to command constructor. |
| tools/Azure.Mcp.Tools.LoadTesting/tests/Azure.Mcp.Tools.LoadTesting.UnitTests/TestResourcesListCommandTests.cs | Updates tests to pass mocked service directly to command constructor. |
| tools/Azure.Mcp.Tools.LoadTesting/tests/Azure.Mcp.Tools.LoadTesting.UnitTests/TestResourceCreateTests.cs | Updates tests to pass mocked service directly to command constructor. |
| tools/Azure.Mcp.Tools.LoadTesting/tests/Azure.Mcp.Tools.LoadTesting.UnitTests/TestGetCommandTests.cs | Updates tests to pass mocked service directly to command constructor. |
| tools/Azure.Mcp.Tools.LoadTesting/tests/Azure.Mcp.Tools.LoadTesting.UnitTests/TestCreateCommandTests.cs | Updates tests to pass mocked service directly to command constructor. |
You can also share your feedback on Copilot code review. Take the survey.
alzimmermsft
approved these changes
Mar 17, 2026
6 tasks
colbytimm
pushed a commit
to colbytimm/microsoft-mcp
that referenced
this pull request
Apr 20, 2026
* Initial plan * refactor: DI refactor for Azure.Mcp.Tools.LoadTesting commands Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> * Delete servers/Azure.Mcp.Server/changelog-entries/1773500000000.yaml Remove unnecessary changelog --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> Co-authored-by: Connie Yau <conniey@microsoft.com>
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.
Removes
context.GetService<ILoadTestingService>()calls fromExecuteAsyncacross all LoadTesting commands, replacing them with constructor-injected dependencies per the pattern established in #158.Commands updated
TestGetCommandTestCreateCommandTestResourceCreateCommandTestResourceListCommandTestRunCreateOrUpdateCommandTestRunGetCommandPattern applied
Tests updated
All unit tests now pass the mock
ILoadTestingServicedirectly to the command constructor instead of registering it in theServiceCollection, removing the indirect DI container dependency from test setup.Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.