-
Notifications
You must be signed in to change notification settings - Fork 1k
Add code coverage for DesignerUtils #13384
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 code coverage for DesignerUtils #13384
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #13384 +/- ##
===================================================
+ Coverage 62.62802% 62.74430% +0.11628%
===================================================
Files 1561 1561
Lines 159839 159997 +158
Branches 14915 14918 +3
===================================================
+ Hits 100104 100389 +285
+ Misses 58960 58833 -127
Partials 775 775
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
...ystem.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerUtilsTests.cs
Outdated
Show resolved
Hide resolved
...ystem.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerUtilsTests.cs
Outdated
Show resolved
Hide resolved
...ystem.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerUtilsTests.cs
Outdated
Show resolved
Hide resolved
...ystem.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerUtilsTests.cs
Outdated
Show resolved
Hide resolved
...ystem.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerUtilsTests.cs
Outdated
Show resolved
Hide resolved
...ystem.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerUtilsTests.cs
Outdated
Show resolved
Hide resolved
...ystem.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerUtilsTests.cs
Outdated
Show resolved
Hide resolved
...ystem.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerUtilsTests.cs
Outdated
Show resolved
Hide resolved
...ystem.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerUtilsTests.cs
Outdated
Show resolved
Hide resolved
...ystem.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerUtilsTests.cs
Outdated
Show resolved
Hide resolved
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 adds comprehensive unit tests for the public methods and properties of DesignerUtils to improve code coverage.
- Adds a new test file (DesignerUtilsTests.cs) covering behaviors such as cursor point retrieval, drawing frames, snap shot generation, and option value retrieval.
- Introduces tests for both expected functioning and error-free execution of various DesignerUtils methods.
Comments suppressed due to low confidence (1)
src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerUtilsTests.cs:18
- [nitpick] The public property 'button' should use PascalCase (e.g. 'Button') to adhere to common naming conventions.
public Button button { get; }
...ystem.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerUtilsTests.cs
Outdated
Show resolved
Hide resolved
@@ -171,11 +162,14 @@ public void LastCursorPoint_ShouldNotThrow_WhenCalled() | |||
} | |||
|
|||
[WinFormsFact] |
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.
This could be refactored for greater clarity:
[WinFormsFact]
public void LastCursorPoint_ShouldReturnValidCoordinates()
{
Point cursorPoint = DesignerUtils.LastCursorPoint;
Rectangle virtualScreen = SystemInformation.VirtualScreen;
cursorPoint.X.Should().BeInRange(virtualScreen.Left, virtualScreen.Right);
cursorPoint.Y.Should().BeInRange(virtualScreen.Top, virtualScreen.Bottom);
}
That said, I'm still unsure this fully addresses Tanya's concern, as DesignerUtils.LastCursorPoint
still relies on a computer-wide resource.
@Tanya-Solyanik , do you think this test is stable enough?
Related #10773
Proposed changes
Add unit test file: DesignerUtilsTests.cs for public methods & properties of the DesignerUtils.cs
Note: working on another PR for the remaining test case
Microsoft Reviewers: Open in CodeFlow