Skip to content

Add code coverage for DataGridViewImageCell #13616

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

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

Conversation

Zheng-Li01
Copy link
Member

@Zheng-Li01 Zheng-Li01 commented Jun 18, 2025

Related #13442

Proposed changes

Add unit test file:DataGridViewImageCellTests.cs for public/protected methods/properties of the DataGridViewImageCell.cs

Microsoft Reviewers: Open in CodeFlow

Copy link

codecov bot commented Jun 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.61283%. Comparing base (ece6f6d) to head (1a6746a).

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #13616         +/-   ##
===================================================
+ Coverage   76.58723%   76.61283%   +0.02559%     
===================================================
  Files           3253        3254          +1     
  Lines         640992      641155        +163     
  Branches       47439       47450         +11     
===================================================
+ Hits          490918      491207        +289     
+ Misses        146541      146391        -150     
- Partials        3533        3557         +24     
Flag Coverage Δ
Debug 76.61283% <100.00000%> (+0.02559%) ⬆️
integration 18.47240% <ø> (-0.00976%) ⬇️
production 51.06554% <ø> (+0.04379%) ⬆️
test 97.41294% <100.00000%> (+0.00119%) ⬆️
unit 48.51603% <ø> (+0.08409%) ⬆️

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.

@Zheng-Li01 Zheng-Li01 added the waiting-review This item is waiting on review by one or more members of team label Jun 18, 2025
@LeafShi1 LeafShi1 requested a review from Copilot June 19, 2025 07:17
Copy link
Contributor

@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 introduces a new suite of unit tests for DataGridViewImageCell, covering its constructors, property getters, layout calculations, painting logic, and ToString behavior.

  • Adds DataGridViewImageCellTests.cs with tests for default ctor behavior, DefaultNewRowValue, content/error bounds, preferred size, painting, and string representation.
  • Uses the test accessor to exercise protected layout and rendering methods.
  • Verifies exception behavior and default values under various DataGridView configurations.
Comments suppressed due to low confidence (2)

src/test/unit/System.Windows.Forms/System/Windows/Forms/DataGridViewImageCellTests.cs:10

  • [nitpick] Property names in C# should use PascalCase. Consider renaming dataGridViewImageCell to Cell or DataGridViewImageCellInstance.
    public DataGridViewImageCell dataGridViewImageCell => new();

src/test/unit/System.Windows.Forms/System/Windows/Forms/DataGridViewImageCellTests.cs:95

  • All GetContentBounds tests cover only the empty‐bounds paths. To improve coverage, add a test where OwningColumn and a valid image value are set so that GetContentBounds returns a non‐empty rectangle.
        Rectangle bounds = (Rectangle)dataGridViewImageCell.TestAccessor().Dynamic.GetContentBounds(g, style, 0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-test coverage waiting-review This item is waiting on review by one or more members of team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant