Skip to content

Add comprehensive tests to improve code coverage for missing lines#118

Closed
Copilot wants to merge 1 commit intodevfrom
copilot/fix-117
Closed

Add comprehensive tests to improve code coverage for missing lines#118
Copilot wants to merge 1 commit intodevfrom
copilot/fix-117

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 19, 2025

This PR addresses the code coverage gaps identified in the Codecov report, where patch coverage was only 57.69% with 11 lines missing coverage across 4 files.

Coverage Improvements

SlimBusEventPublisher.cs - Added integration tests covering:

  • Event publishing with IEventItem objects and header propagation from AdditionalData
  • Event publishing with regular objects (non-IEventItem path)
  • Cancellation token handling for both scenarios
  • Empty AdditionalData dictionary edge case

EventExtensions.cs - Added unit tests covering:

  • GetEntityKeyValues method with entities that have primary keys
  • Key-value extraction and dictionary creation logic

IEventItem.cs - Added comprehensive tests for the EventItem record covering:

  • EventType property behavior and automatic type name resolution
  • AdditionalData dictionary initialization and case-insensitive behavior
  • Multiple entries, null value handling, and dictionary operations

IHook.cs - Added tests for the HookAsync abstract base class covering:

  • Default implementations of RunBeforeSaveAsync and RunAfterSaveAsync
  • Cancellation token support in both hook methods
  • Base class functionality when inherited by concrete implementations

Test Quality

All tests follow the existing project patterns using xUnit and Shouldly, with integration tests using real services where appropriate rather than excessive mocking. The tests target the specific missing lines identified in the coverage report while maintaining the project's high standards for test quality.

Fixes #117.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@baoduy baoduy closed this Sep 19, 2025
@baoduy baoduy deleted the copilot/fix-117 branch September 19, 2025 02:12
@baoduy baoduy restored the copilot/fix-117 branch September 19, 2025 02:12
Copilot AI changed the title [WIP] ## [Codecov](https://app.codecov.io/gh/baoduy/DKNet/pull/115?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Steven+Hoang) Report Add comprehensive tests to improve code coverage for missing lines Sep 19, 2025
Copilot AI requested a review from baoduy September 19, 2025 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants