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 code coverage for DataGridViewLinkColumn #12522

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 Nov 21, 2024

related #10453

Proposed changes

Add unit tests for DataGridViewLinkColumn.cs to test its properties & methods & events

Microsoft Reviewers: Open in CodeFlow

Copy link

codecov bot commented Nov 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.78523%. Comparing base (a3973fb) to head (8829fb8).
Report is 35 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #12522         +/-   ##
===================================================
+ Coverage   75.71735%   75.78523%   +0.06788%     
===================================================
  Files           3152        3158          +6     
  Lines         635709      636314        +605     
  Branches       46970       47004         +34     
===================================================
+ Hits          481342      482232        +890     
+ Misses        150932      150619        -313     
- Partials        3435        3463         +28     
Flag Coverage Δ
Debug 75.78523% <100.00000%> (+0.06788%) ⬆️
integration 18.18211% <ø> (-0.08806%) ⬇️
production 49.38847% <ø> (+0.11096%) ⬆️
test 97.04712% <100.00000%> (-0.00319%) ⬇️
unit 46.60136% <ø> (+0.34665%) ⬆️

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

---- 🚨 Try these New Features:

@Zheng-Li01 Zheng-Li01 added the waiting-review This item is waiting on review by one or more members of team label Nov 21, 2024
_column.UseColumnTextForLinkValue = true;
_column.VisitedLinkColor = Color.Green;

var clone = (DataGridViewLinkColumn)_column.Clone();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please declare variables as specific types.

Also, please dispose of the created control:

using DataGridViewLinkColumn clone = (DataGridViewLinkColumn)_column.Clone(); 

Both situations happen in other lines of code.

getProperty().Should().Be(value);
}

private void TestPropertySetWithDataGridView<T>(Action<T> setProperty, Func<T> getProperty, Func<T> getCellProperty, T value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While encapsulating repetitive code is generally a good practice, in unit tests, it can make debugging more challenging and obscure the clear intent of the test. When an error occurs, having test logic directly in the test method makes it easier to trace issues through the call stack without needing to inspect helper methods. While encapsulation may be useful for complex setups or repetitive patterns, prioritizing readability and straightforward error tracking often leads to more maintainable tests.

I’d recommend refactoring the code to inline the logic currently encapsulated in TestPropertySetWithDataGridView directly into the relevant test methods. This will make the tests easier to read and debug, especially when tracking errors.

@ricardobossan ricardobossan added the 📭 waiting-author-feedback The team requires more information from the author 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 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.

2 participants