Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged

Conversation

Zheng-Li01
Copy link
Member

@Zheng-Li01 Zheng-Li01 commented Apr 28, 2025

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

Copy link

codecov bot commented Apr 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.74430%. Comparing base (7774491) to head (61637e4).
Report is 8 commits behind head on main.

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                 
Flag Coverage Δ
Debug 62.74430% <100.00000%> (+0.11628%) ⬆️
integration 11.34158% <ø> (+0.01466%) ⬆️
production 40.94515% <ø> (+0.13602%) ⬆️
test 95.70296% <100.00000%> (+0.00439%) ⬆️
unit 38.34396% <ø> (+0.13603%) ⬆️

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@Copilot Copilot AI left a 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; }

@Zheng-Li01 Zheng-Li01 added the waiting-review This item is waiting on review by one or more members of team label Apr 29, 2025
@Tanya-Solyanik Tanya-Solyanik merged commit 5f9458e into dotnet:main Apr 29, 2025
8 checks passed
@dotnet-policy-service dotnet-policy-service bot removed the waiting-review This item is waiting on review by one or more members of team label Apr 29, 2025
@@ -171,11 +162,14 @@ public void LastCursorPoint_ShouldNotThrow_WhenCalled()
}

[WinFormsFact]
Copy link
Member

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?

@Zheng-Li01 Zheng-Li01 deleted the Add_code_coverage_for_DesignerUtils branch April 30, 2025 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants