Skip to content

Guarantee FakeHttpMessageHandler disposal in AgentBlueprintServiceTests#297

Merged
gwharris7 merged 2 commits intousers/grantharris/fix-orphaned-instancesfrom
copilot/sub-pr-284
Feb 27, 2026
Merged

Guarantee FakeHttpMessageHandler disposal in AgentBlueprintServiceTests#297
gwharris7 merged 2 commits intousers/grantharris/fix-orphaned-instancesfrom
copilot/sub-pr-284

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

Explicit handler.Dispose() calls at the end of test bodies are skipped when assertions throw, leaking the handler and any queued HttpResponseMessage objects.

Changes

  • 3 tests using CreateServiceWithFakeHandler() — wrap test body in using (handler) { ... } (tuple destructuring prevents using var on the declaration)
  • 1 test with direct handler creation — replace var handler = new FakeHttpMessageHandler() + trailing Dispose() with using var handler = ...
// Before — disposal skipped if assertion throws
var (service, handler) = CreateServiceWithFakeHandler();
// ... assertions ...
handler.Dispose();

// After — disposal guaranteed
var (service, handler) = CreateServiceWithFakeHandler();
using (handler)
{
    // ... assertions ...
}

💡 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.

Co-authored-by: gwharris7 <96964444+gwharris7@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on cleanup agent instances in a365 cleanup blueprint Guarantee FakeHttpMessageHandler disposal in AgentBlueprintServiceTests Feb 27, 2026
@gwharris7 gwharris7 marked this pull request as ready for review February 27, 2026 17:46
@gwharris7 gwharris7 requested review from a team as code owners February 27, 2026 17:46
@gwharris7 gwharris7 merged commit 5813cb6 into users/grantharris/fix-orphaned-instances Feb 27, 2026
2 checks passed
@gwharris7 gwharris7 deleted the copilot/sub-pr-284 branch February 27, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants