-
-
Notifications
You must be signed in to change notification settings - Fork 362
test(DataPackageAdapter): add unit test #6353
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
Reviewer's GuideThis PR enhances the TCP socket factory unit tests by refactoring the client creation to support DI-based ISocketClientProvider mocks, integrating the DataPackageAdapter into test flows, converting outdated DataPackageHandlerBase mocks into provider implementations, and updating the core DataPackageHandler abstraction and auto-receive logic to align with these patterns. Class diagram for updated DataPackageHandler abstractionclassDiagram
class IDataPackageHandler {
+Func<ReadOnlyMemory<byte>, ValueTask>? ReceivedCallBack
+ValueTask ReceiveAsync(ReadOnlyMemory<byte> data, CancellationToken token = default)
}
class DataPackageHandlerBase {
<<abstract>>
+ValueTask ReceiveAsync(ReadOnlyMemory<byte> data, CancellationToken token = default)
}
IDataPackageHandler <|.. DataPackageHandlerBase
Class diagram for TcpSocketClientBase auto-receive logic updateclassDiagram
class TcpSocketClientBase {
- CancellationTokenSource? _receiveCancellationTokenSource
+ValueTask<Memory<byte>> ReceiveAsync(CancellationToken token)
-ValueTask AutoReceiveAsync()
}
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @ArgoZhang - I've reviewed your changes - here's some feedback:
- When registering mock ISocketClientProvider implementations in CreateClient, consider using ServiceCollection.Replace or removing existing registrations to ensure only your mock provider is resolved.
- The updated AutoReceiveAsync loop now uses
while(true)but drops the_receiveCancellationTokenSource.IsCancellationRequestedcheck—re-add a cancellation check to avoid potential infinite loops. - You removed the abstract
SendAsyncfrom IDataPackageHandler and DataPackageHandlerBase—verify that all existing handlers are updated accordingly or provide a clear migration path for consumers.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- When registering mock ISocketClientProvider implementations in CreateClient, consider using ServiceCollection.Replace or removing existing registrations to ensure only your mock provider is resolved.
- The updated AutoReceiveAsync loop now uses `while(true)` but drops the `_receiveCancellationTokenSource.IsCancellationRequested` check—re-add a cancellation check to avoid potential infinite loops.
- You removed the abstract `SendAsync` from IDataPackageHandler and DataPackageHandlerBase—verify that all existing handlers are updated accordingly or provide a clear migration path for consumers.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6353 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 717 718 +1
Lines 31573 31572 -1
Branches 4462 4462
=========================================
- Hits 31573 31572 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6352
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Enhance TcpSocketFactory unit tests by introducing DI-based mock socket providers, refactoring test adapters to use DataPackageAdapter, simplifying the package handler interface, and improving the auto-receive loop behavior.
New Features:
Bug Fixes:
Enhancements:
Tests: