Skip to content

test(DataTableDynamicContext): improve code coverage#7915

Merged
ArgoZhang merged 2 commits intomainfrom
test-table
Apr 26, 2026
Merged

test(DataTableDynamicContext): improve code coverage#7915
ArgoZhang merged 2 commits intomainfrom
test-table

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Apr 26, 2026

Link issues

fixes #7914

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Improve unit test coverage for dynamic data table context and related data row extensions.

Tests:

  • Add a unit test verifying AddAsync behavior with auto-increment DataTable columns in DataTableDynamicContext.
  • Introduce a reflection-based unit test for DataRowExtensions.IsDeletedOrDetached covering deleted, detached, and attached DataRow states.

Copilot AI review requested due to automatic review settings April 26, 2026 01:10
@bb-auto bb-auto Bot added the test This is unit test label Apr 26, 2026
@bb-auto bb-auto Bot added this to the v10.5.0 milestone Apr 26, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Apr 26, 2026

Reviewer's Guide

Adds new unit tests to improve coverage of DataTableDynamicContext.AddAsync behavior with auto-increment columns and the DataRowExtensions.IsDeletedOrDetached extension method using reflection-based invocation.

File-Level Changes

Change Details Files
Cover DataTableDynamicContext.AddAsync behavior when working with auto-increment DataColumn values.
  • Create a DataTable with an auto-increment integer Id column and a string Name column.
  • Seed the table with an initial row and construct a DataTableDynamicContext from it.
  • Invoke AddAsync with an empty value set to trigger auto-increment logic.
  • Assert row count and Id values to validate correct auto-increment behavior and ordering.
test/UnitTest/Dynamic/DataTableDynamicContextTest.cs
Introduce reflection-based tests validating the DataRowExtensions.IsDeletedOrDetached extension method across DataRow states.
  • Load the DataRowExtensions type from the BootstrapBlazor assembly via Type.GetType.
  • Use reflection to obtain the public static IsDeletedOrDetached method.
  • Create a DataTable and DataRow instances in various states: added, accepted, deleted, detached, and re-attached.
  • Assert that IsDeletedOrDetached returns expected results for each DataRow state by invoking the method via reflection.
test/UnitTest/Extensions/DataRowExtensionsTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#7914 Add or enhance unit tests for DataTableDynamicContext to improve its code coverage.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The DataRowExtensionsTest.IsDeletedOrDetached_Ok test relies on Type.GetType("BootstrapBlazor.Components.DataRowExtensions, BootstrapBlazor"), which is brittle with respect to namespace/assembly renames; consider referencing the type directly (e.g., via typeof(...)) or another strongly-typed mechanism instead of string-based reflection.
  • In AddAsync_AutoIncrementColumn_Ok, the assertions depend on both the auto-incremented Id values and the exact row ordering; if row insertion order is not a guaranteed contract of DataTableDynamicContext.AddAsync, consider checking the Id values independently of row index to avoid a fragile test.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `DataRowExtensionsTest.IsDeletedOrDetached_Ok` test relies on `Type.GetType("BootstrapBlazor.Components.DataRowExtensions, BootstrapBlazor")`, which is brittle with respect to namespace/assembly renames; consider referencing the type directly (e.g., via `typeof(...)`) or another strongly-typed mechanism instead of string-based reflection.
- In `AddAsync_AutoIncrementColumn_Ok`, the assertions depend on both the auto-incremented Id values and the exact row ordering; if row insertion order is not a guaranteed contract of `DataTableDynamicContext.AddAsync`, consider checking the Id values independently of row index to avoid a fragile test.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (605f639) to head (baf830c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #7915      +/-   ##
===========================================
+ Coverage   99.98%   100.00%   +0.01%     
===========================================
  Files         765       765              
  Lines       34325     34325              
  Branches     4710      4710              
===========================================
+ Hits        34321     34325       +4     
+ Misses          2         0       -2     
+ Partials        2         0       -2     
Flag Coverage Δ
BB 100.00% <ø> (?)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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
Copy Markdown
Contributor

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

Improves unit test coverage around DataTableDynamicContext.AddAsync behavior with auto-increment columns and adds direct coverage for DataRowExtensions.IsDeletedOrDetached.

Changes:

  • Added a new unit test validating DataRowExtensions.IsDeletedOrDetached across Unchanged, Deleted, Detached, and Added row states.
  • Added a new unit test ensuring DataTableDynamicContext.AddAsync correctly handles DataColumn.AutoIncrement by skipping assignment and allowing the DataTable to generate values.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/UnitTest/Extensions/DataRowExtensionsTest.cs New reflection-based unit test covering IsDeletedOrDetached for multiple DataRowState values.
test/UnitTest/Dynamic/DataTableDynamicContextTest.cs Adds AddAsync_AutoIncrementColumn_Ok to cover the auto-increment skip path in AddAsync.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ArgoZhang ArgoZhang merged commit d22ede2 into main Apr 26, 2026
10 checks passed
@ArgoZhang ArgoZhang deleted the test-table branch April 26, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test This is unit test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(DataTableDynamicContext): improve code coverage

2 participants