-
Notifications
You must be signed in to change notification settings - Fork 1.1k
.NET: Improve unit test coverage for Microsoft.Agents.AI.OpenAI #3349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
|
@copilot Address format issues. |
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
|
Formatting error still persists, getting: |
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR improves unit test coverage for the Microsoft.Agents.AI.OpenAI project from 66.6% line / 50% branch to meet the 85% target. The PR adds 47 new unit tests (increasing from 43 to 90 total tests) targeting previously uncovered code paths in internal streaming classes and extension methods.
Changes:
- Created 4 new test files for testing internal streaming classes and extension methods
- Extended 2 existing test files with additional test cases for tool conversions and ResponseItem overloads
- Added InternalsVisibleTo attribute to expose internal types to the test project
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| AgentResponseExtensionsTests.cs | New test file covering AsOpenAIChatCompletion and AsOpenAIResponse extension methods with null checks and conversion paths |
| AsyncStreamingChatCompletionUpdateCollectionResultTests.cs | New test file testing GetContinuationToken, GetRawPagesAsync, and iteration behavior for streaming chat completion updates |
| AsyncStreamingResponseUpdateCollectionResultTests.cs | New test file covering streaming response update filtering logic including RawRepresentation and ChatResponseUpdate handling |
| StreamingUpdatePipelineResponseTests.cs | New test file testing PipelineResponse properties, content handling, and unsupported buffering operations |
| AIAgentWithOpenAIExtensionsTests.cs | Extended with ResponseItem overload tests covering null argument validation and method invocation |
| OpenAIAssistantClientExtensionsTests.cs | Extended with tool conversion tests for HostedCodeInterpreterTool, HostedFileSearchTool, HostedFileContent, and HostedVectorStoreContent |
| Microsoft.Agents.AI.OpenAI.csproj | Added InternalsVisibleTo attribute to expose internal types to unit tests |
Motivation and Context
Code coverage for
Microsoft.Agents.AI.OpenAIwas at 66.6% line / 50% branch coverage, which is below the required 85% target. Several internal classes had 0-50% coverage includingAsyncStreamingResponseUpdateCollectionResult(0%),StreamingUpdatePipelineResponse(13.3%),AgentResponseExtensions(50%), andAIAgentWithOpenAIExtensions(50%).Description
This PR improves unit test coverage for the Microsoft.Agents.AI.OpenAI project by adding 47 new unit tests (43 → 90 total) targeting uncovered code paths.
New test files created:
AgentResponseExtensionsTests.cs- Tests forAsOpenAIChatCompletionandAsOpenAIResponseextension methodsAsyncStreamingChatCompletionUpdateCollectionResultTests.cs- Tests for internal streaming chat completion classAsyncStreamingResponseUpdateCollectionResultTests.cs- Tests for internal streaming response classStreamingUpdatePipelineResponseTests.cs- Tests for internal pipeline response classExtended existing tests:
AIAgentWithOpenAIExtensionsTests.cs- AddedResponseItemoverloads forRunAsync/RunStreamingAsyncOpenAIAssistantClientExtensionsTests.cs- Added tool conversion paths (HostedCodeInterpreterTool,HostedFileSearchTool,HostedFileContent,HostedVectorStoreContent)Infrastructure changes:
InternalsVisibleToattribute to expose internal types to the test projectTest Results: All 90 tests passing
Contribution Checklist
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.