Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Syareel-Sukeri
Copy link
Contributor

@Syareel-Sukeri Syareel-Sukeri commented Nov 15, 2024

Related #10773

Proposed changes

  1. Add unit test MaskedTextBoxDesignerActionListTests.cs for public properties and method of the MaskedTextBoxDesignerActionList.
  2. Enable nullability in MaskedTextBoxDesignerActionListTests.cs.
Microsoft Reviewers: Open in CodeFlow

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 95.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 75.77638%. Comparing base (65f897b) to head (8382481).
Report is 46 commits behind head on main.

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     
Flag Coverage Δ
Debug 75.77638% <95.00000%> (+0.12230%) ⬆️
integration 18.26795% <ø> (+0.01887%) ⬆️
production 49.39852% <ø> (+0.20019%) ⬆️
test 97.05072% <95.00000%> (+0.02048%) ⬆️
unit 46.37650% <ø> (+0.22053%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

---- 🚨 Try these New Features:

@Syareel-Sukeri Syareel-Sukeri added the waiting-review This item is waiting on review by one or more members of team label Nov 18, 2024

public MaskedTextBoxDesignerActionListTests()
{
_mockTypeDiscoveryService = new Mock<ITypeDiscoveryService>();
Copy link
Member

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;
Copy link
Member

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.

Before SetMask() is called:
image

After SetMask() is called:
image

@ricardobossan ricardobossan added the 📭 waiting-author-feedback The team requires more information from the author label Nov 20, 2024
@LeafShi1 LeafShi1 removed the waiting-review This item is waiting on review by one or more members of team label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📭 waiting-author-feedback The team requires more information from the author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants