-
-
Notifications
You must be signed in to change notification settings - Fork 231
Implement IMimeMessageData #1326
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
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1326 +/- ##
==========================================
- Coverage 37.50% 37.19% -0.32%
==========================================
Files 175 176 +1
Lines 38872 40858 +1986
==========================================
+ Hits 14579 15197 +618
- Misses 23813 25236 +1423
+ Partials 480 425 -55 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <[email protected]>
…reMock.Net into IMimeMessageData
Co-authored-by: Copilot <[email protected]>
…artMatcher.cs Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
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 introduces typed abstractions for MIME messages and parts, replacing untyped object
usage with new IMimeMessageData
and IMimePartData
interfaces, and updates utilities, matchers, and tests to leverage these wrappers.
- Define
IMimeMessageData
,IMimePartData
,IMimeEntityData
,IContentTypeData
, andIContentDispositionData
interfaces. - Implement wrapper classes (
MimeMessageDataWrapper
,MimePartDataWrapper
, etc.) that adapt MimeKit types to the new interfaces. - Refactor
IMimeKitUtils
,RequestMessage
,RequestMessageMultiPartMatcher
, andMimePartMatcher
to use the new abstractions and remove legacyGetBodyParts
. - Update tests to use
message.BodyParts
instead ofMimeKitUtils.GetBodyParts
.
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
test/WireMock.Net.Tests/Matchers/MimePartMatcherTests.cs | Switch tests to use BodyParts property instead of helper method |
src/WireMock.Net.Shared/Util/IMimeKitUtils.cs | Change LoadFromStream /TryGetMimeMessage to return interfaces |
src/WireMock.Net.Shared/Matchers/IMimePartMatcher.cs | Update matcher interface to accept IMimePartData |
src/WireMock.Net.Minimal/RequestMessage.cs | Change BodyAsMimeMessage to IMimeMessageData |
src/WireMock.Net.Minimal/Matchers/Request/RequestMessageMultiPartMatcher.cs | Iterate message.BodyParts instead of GetBodyParts |
src/WireMock.Net.MimePart/Util/MimeKitUtils.cs | Implement new interface methods and remove old GetBodyParts |
src/WireMock.Net.MimePart/Models/*.cs | Add wrapper implementations for all new MIME interfaces |
src/WireMock.Net.MimePart/Matchers/MimePartMatcher.cs | Refactor matcher to use IMimePartData and new wrappers |
src/WireMock.Net.Abstractions/Models/Mime/*.cs | Define the seven new MIME-related interfaces |
Comments suppressed due to low confidence (1)
src/WireMock.Net.MimePart/Models/ContentDispositionDataWrapper.cs:37
- Returning
object
forParameters
may force consumers to cast. Consider exposing a more specific type (e.g.,IReadOnlyDictionary<string, string>
orIEnumerable<string>
) to make the API easier to use and reduce the need for casting.
public object Parameters => _contentDisposition.Parameters;
@@ -52,21 +53,21 @@ public MimePartMatcher( | |||
_funcs = | |||
[ | |||
mp => ContentTypeMatcher?.IsMatch(GetContentTypeAsString(mp.ContentType)) ?? MatchScores.Perfect, | |||
mp => ContentDispositionMatcher?.IsMatch(mp.ContentDisposition.ToString().Replace("Content-Disposition: ", string.Empty)) ?? MatchScores.Perfect, | |||
mp => ContentTransferEncodingMatcher?.IsMatch(mp.ContentTransferEncoding.ToString().ToLowerInvariant()) ?? MatchScores.Perfect, | |||
mp => ContentDispositionMatcher?.IsMatch(mp.ContentDisposition?.ToString()?.Replace("Content-Disposition: ", string.Empty)) ?? MatchScores.Perfect, |
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.
Instead of calling ToString and replacing the header prefix, consider using the Disposition
property on IContentDispositionData
directly (e.g., mp.ContentDisposition?.Disposition
) to match the value more explicitly.
mp => ContentDispositionMatcher?.IsMatch(mp.ContentDisposition?.ToString()?.Replace("Content-Disposition: ", string.Empty)) ?? MatchScores.Perfect, | |
mp => ContentDispositionMatcher?.IsMatch(mp.ContentDisposition?.Disposition) ?? MatchScores.Perfect, |
Copilot uses AI. Check for mistakes.
No description provided.