-
Notifications
You must be signed in to change notification settings - Fork 986
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
base: main
Are you sure you want to change the base?
Add code coverage for DataGridViewLinkColumn #12522
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
_column.UseColumnTextForLinkValue = true; | ||
_column.VisitedLinkColor = Color.Green; | ||
|
||
var clone = (DataGridViewLinkColumn)_column.Clone(); |
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.
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) |
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.
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.
related #10453
Proposed changes
Add unit tests for DataGridViewLinkColumn.cs to test its properties & methods & events
Microsoft Reviewers: Open in CodeFlow