.NET: Add dedicated Foundry.Hosting UnitTest project#5592
Conversation
Move all Hosting/* tests, three toolbox TestData JSONs, and the FakeAuthenticationTokenProvider/HttpHandlerAssert/TestDataUtil helpers (trimmed to toolbox getters) into a new Microsoft.Agents.AI.Foundry.Hosting.UnitTests project. Add it to the slnx and grant the new assembly InternalsVisibleTo from Microsoft.Agents.AI.Foundry and Microsoft.Agents.AI.Foundry.Hosting.
Rename namespaces from Microsoft.Agents.AI.Foundry.UnitTests(.Hosting) to Microsoft.Agents.AI.Foundry.Hosting.UnitTests across all moved tests, the duplicated helpers, and the trimmed TestDataUtil. Also fixes the prior namespace inconsistency in FoundryToolboxTests.
Replace the WorkflowIntegrationTests file (an IT-named file inside a UT project) with two SUT-focused files plus a shared test-doubles file: - AgentFrameworkResponseHandlerWorkflowTests.cs - the 5 handler-driven tests that exercise AgentFrameworkResponseHandler with a real workflow agent. - OutputConverterWorkflowTests.cs - the 5 OutputConverter tests driven by hand-crafted update sequences mirroring real workflow patterns. - WorkflowTestAgents.cs - StreamingTextAgent and ThrowingStreamingAgent extracted as internal types used by both files.
Now that Hosting tests live in their own project: - drop the Compile Remove guard for the Hosting subfolder, - drop the .NETCoreApp-only PackageReferences (Azure.AI.AgentServer.Responses, Microsoft.AspNetCore.TestHost, OpenTelemetry, OpenTelemetry.Exporter.InMemory), - drop the conditional ProjectReference to Microsoft.Agents.AI.Foundry.Hosting, - delete the three Toolbox JSON files and the matching Toolbox getters in TestDataUtil.
…Foundry.Hosting' The new project namespace is Microsoft.Agents.AI.Foundry.Hosting.UnitTests, which already brings the parent Microsoft.Agents.AI.Foundry.Hosting namespace into scope. The explicit using statement is therefore redundant (IDE0005). Caught by 'dotnet format --verify-no-changes' running on Linux against the .NET 10 SDK.
df8144a to
cde10f0
Compare
The non-hosting Foundry.UnitTests project no longer holds any Hosting tests after the split, so it doesn't need access to internal types in Microsoft.Agents.AI.Foundry.Hosting. Only Microsoft.Agents.AI.Foundry.Hosting.UnitTests needs it.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Splits Foundry.Hosting-related unit tests out of Microsoft.Agents.AI.Foundry.UnitTests into a new dedicated Microsoft.Agents.AI.Foundry.Hosting.UnitTests project, aligning with the Foundry/Foundry.Hosting source split.
Changes:
- Adds a new
Microsoft.Agents.AI.Foundry.Hosting.UnitTeststest project (csproj, helpers, workflow-focused tests, toolbox test data). - Trims
Microsoft.Agents.AI.Foundry.UnitTeststo remove Hosting-only dependencies and toolbox test data/getters. - Updates
InternalsVisibleToand solution membership for the new test project.
Reviewed changes
Copilot reviewed 24 out of 27 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/TestDataUtil.cs | Removes toolbox JSON loading/getters from the Foundry test utilities. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Microsoft.Agents.AI.Foundry.UnitTests.csproj | Drops Hosting-only package refs/compile guards/toolbox data from the Foundry unit test project. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Hosting/WorkflowIntegrationTests.cs | Removes the older large workflow integration test file (replaced by new workflow-focused tests). |
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Hosting/ServiceCollectionExtensionsTests.cs | Updates test namespace for Hosting test split. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Hosting/OutputConverterTests.cs | Updates test namespace for Hosting test split. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Hosting/InputConverterTests.cs | Updates test namespace for Hosting test split. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Hosting/HostedOutboundUserAgentTests.cs | Updates test namespace for Hosting test split. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Hosting/FoundryToolboxTests.cs | Updates namespace to Hosting test project namespace. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Hosting/FoundryToolboxServiceTests.cs | Updates test namespace for Hosting test split. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Hosting/FoundryToolboxBearerTokenHandlerTests.cs | Updates test namespace for Hosting test split. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Hosting/FoundryAIToolExtensionsTests.cs | Updates test namespace for Hosting test split. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Hosting/DelegatingResponsesClientTests.cs | Updates test namespace for Hosting test split. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Hosting/AgentFrameworkResponseHandlerTests.cs | Updates test namespace for Hosting test split. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Hosting/AgentFrameworkResponseHandlerTelemetryTests.cs | Updates test namespace for Hosting test split. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/WorkflowTestAgents.cs | Adds shared workflow test doubles (streaming/throwing agents) used by new workflow tests. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/TestDataUtil.cs | Adds Hosting test utility for toolbox JSON test data. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/OutputConverterWorkflowTests.cs | Adds focused OutputConverter workflow-pattern tests (hand-crafted update sequences). |
| dotnet/tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests.csproj | Adds new Hosting unit test project and its dependencies/test data. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/HttpHandlerAssert.cs | Duplicates helper HTTP handler assertion utility into the new Hosting test project. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/FakeAuthenticationTokenProvider.cs | Duplicates a fake token provider helper into the new Hosting test project. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/AgentFrameworkResponseHandlerWorkflowTests.cs | Adds focused workflow-backed agent tests for AgentFrameworkResponseHandler. |
| dotnet/src/Microsoft.Agents.AI.Foundry/Microsoft.Agents.AI.Foundry.csproj | Grants internals visibility to the new Hosting unit test assembly. |
| dotnet/src/Microsoft.Agents.AI.Foundry.Hosting/Microsoft.Agents.AI.Foundry.Hosting.csproj | Grants internals visibility to the new Hosting unit test assembly. |
| dotnet/agent-framework-dotnet.slnx | Adds the new Hosting unit test project to the solution. |
…esClient Address westey-m's review feedback on PR microsoft#5453: `Delegating*` is conventionally reserved for inheritable base classes (mirroring `DelegatingHandler`) where consumers override one or two members. This polyfill is sealed and only injects the User-Agent supplement, so the new name reflects its actual purpose. Renamed via `git mv` to preserve history: * `src/Microsoft.Agents.AI.Foundry.Hosting/DelegatingResponsesClient.cs` to `UserAgentResponsesClient.cs` * `tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/DelegatingResponsesClientTests.cs` to `UserAgentResponsesClientTests.cs` Class, constructor, and all references updated across: * `src/.../UserAgentResponsesClient.cs` (class + constructor + internal log message) * `src/.../ServiceCollectionExtensions.cs` (cref + type check + instantiation) * `src/.../HostedAgentUserAgentPolicy.cs` (cref) * `tests/Foundry.UnitTests/RequestOptionsExtensionsTests.cs` (comment) * `tests/Foundry.Hosting.UnitTests/UserAgentResponsesClientTests.cs` (class + cref + instantiations)
There was a problem hiding this comment.
Automated Code Review
Reviewers: 4 | Confidence: 87%
✓ Correctness
This PR is a clean refactoring that splits hosting-specific tests from the Foundry.UnitTests project into a dedicated Foundry.Hosting.UnitTests project and renames DelegatingResponsesClient to UserAgentResponsesClient. The structural changes (file moves, namespace updates, InternalsVisibleTo adjustments, csproj restructuring) are correct. One correctness issue exists in the extracted test helpers: the
StreamingTextAgentandThrowingStreamingAgentclasses usepublic new string Idto shadow the non-virtual baseAIAgent.Idproperty, which means the custom IDs are invisible when the agents are accessed polymorphically throughAIAgent— as the workflow execution machinery does. The intended fix is to override the virtualIdCoreproperty instead.
✓ Security Reliability
This PR cleanly refactors
DelegatingResponsesClient→UserAgentResponsesClientand splits hosting-related unit tests fromMicrosoft.Agents.AI.Foundry.UnitTestsinto a newMicrosoft.Agents.AI.Foundry.Hosting.UnitTestsproject. The production code changes are limited to doc-comment updates and type reference renames with no behavioral differences. Test files are moved via git renames (so the oldHosting/directory will be empty post-merge) and the old csproj correctly removes its conditionalCompile Removeand hosting project reference. All four previously-reviewed issues were resolved. No new security or reliability concerns were identified.
✓ Test Coverage
This PR is a well-executed structural refactoring that splits hosting-related tests into a separate
Microsoft.Agents.AI.Foundry.Hosting.UnitTestsproject and renamesDelegatingResponsesClienttoUserAgentResponsesClient. All 167 test methods across 12 test files are preserved: the deletedWorkflowIntegrationTests.cs(10 tests) is cleanly split intoAgentFrameworkResponseHandlerWorkflowTests.cs(5 handler-level tests) andOutputConverterWorkflowTests.cs(5 converter-level tests) with shared test agents extracted toWorkflowTestAgents.cs. Test data files and utilities are properly duplicated between projects since bothFakeAuthenticationTokenProviderandHttpHandlerAssertare still needed by non-hosting tests in the original project. No test coverage gaps were found.
✓ Design Approach
I did not find a design-approach issue in this diff. The main changes are test-project extraction for hosting-specific coverage and a terminology rename from
DelegatingResponsesClienttoUserAgentResponsesClient; both appear aligned with the underlying architecture rather than masking a deeper problem.
Automated review by rogerbarreto's agents
Summary
Splits the Foundry-hosting unit tests out of
Microsoft.Agents.AI.Foundry.UnitTestsinto a new dedicatedMicrosoft.Agents.AI.Foundry.Hosting.UnitTestsproject, mirroring the parallelsrc/Microsoft.Agents.AI.Foundry↔src/Microsoft.Agents.AI.Foundry.Hostingsplit.Motivation
Foundry.UnitTestswas carrying.NETCoreApp-only conditional packages, aProjectReferencetoFoundry.Hosting, and aCompile Remove="Hosting\**"guard purely so the Hosting tests could live next to the Foundry tests on the multi-TFM matrix.TargetFrameworksCoreset (net10/9/8) without conditionals.What changed
ed1e7866dgit mv12Hosting/*.csfiles, copyFakeAuthenticationTokenProviderandHttpHandlerAssert, copy 3 toolbox JSONs, add a trimmedTestDataUtil(toolbox getters only). New csproj.slnxentry.InternalsVisibleTogranted fromFoundryandFoundry.Hosting.e04205804Microsoft.Agents.AI.Foundry.Hosting.UnitTests(also fixes a pre-existing inconsistency inFoundryToolboxTests).4a0a768deWorkflowIntegrationTests.cs(an IT-named file inside a UT project) with two SUT-focused files:AgentFrameworkResponseHandlerWorkflowTests+OutputConverterWorkflowTests, plus a sharedWorkflowTestAgents.cscontaining the test doubles.e36d9054eFoundry.UnitTestscsproj: drop the Hosting compile-remove guard, the four.NETCoreApp-only packages, the conditionalFoundry.HostingProjectReference, the three toolbox JSONs, and the toolbox getters inTestDataUtil.df8144a0dusing Microsoft.Agents.AI.Foundry.Hostingfrom the moved files (already in scope from the new namespace).Verification
dotnet build agent-framework-dotnet.slnx --tl:offclean.dotnet format --verify-no-changesclean on both csprojs (run on Linux against .NET 10.0.203).Notes for reviewers
FakeAuthenticationTokenProvider,HttpHandlerAssert) are duplicated between the two test projects intentionally, matching the repo convention of fully self-contained UnitTests projects (no shared helper project, no inter-test-project ProjectReferences).CA1812onAzureAIProjectChatClientExtensionsTests.TestChatClientshows up only when format runs against the Linux .NET 10 SDK; the file is not in this PR's diff.