-
Notifications
You must be signed in to change notification settings - Fork 986
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
Add unit test for MaskedTextBoxDesignerActionList #12491
base: main
Are you sure you want to change the base?
Add unit test for MaskedTextBoxDesignerActionList #12491
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12491 +/- ##
===================================================
+ Coverage 75.65407% 75.77638% +0.12230%
===================================================
Files 3150 3154 +4
Lines 635831 635867 +36
Branches 47020 46978 -42
===================================================
+ Hits 481032 481837 +805
+ Misses 151352 150594 -758
+ Partials 3447 3436 -11
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
||
public MaskedTextBoxDesignerActionListTests() | ||
{ | ||
_mockTypeDiscoveryService = new Mock<ITypeDiscoveryService>(); |
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.
Since these fields are explicitly defined, their initialization could be simplified by just calling new()
.
_mockHelpService.Object); | ||
|
||
resultMask.Should().NotBeNull(); | ||
expectedMask = resultMask ?? expectedMask; |
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.
It seems that expectedMask
will always end up as an empty string, even though it’s initially assigned the value "000-00-0000"
. This happens because resultMask
evaluates to an empty string, and the fallback on line 73 (expectedMask = resultMask ?? expectedMask
) causes expectedMask
to be overridden.
Additionally, _maskedTextBox.Mask
starts as an empty string before SetMask()
is called and remains unchanged afterward. While the test passes, it doesn’t validate whether SetMask()
updates _maskedTextBox.Mask
as intended. The test, in its current form, doesn’t seem to verify meaningful behavior.
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.
"MaskPropertyEditor.EditMask" is a regular static method and cannot be mocked directly. Do you have any suggestions on how to handle this situation effectively?
Related #10773
Proposed changes
Microsoft Reviewers: Open in CodeFlow