Skip to content

test: Unit tests for IMediatorSendOnly#403

Merged
samtrion merged 1 commit into
mainfrom
copilot/add-unit-tests-for-imediator-sendonly
Apr 16, 2026
Merged

test: Unit tests for IMediatorSendOnly#403
samtrion merged 1 commit into
mainfrom
copilot/add-unit-tests-for-imediator-sendonly

Conversation

Copilot AI commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Adds contract and DI integration tests for IMediatorSendOnly to guard against regressions in the interface hierarchy and service registration.

Changes

  • New file: IMediatorSendOnlyTests.cs — four focused tests:
    • IMediator is assignable to IMediatorSendOnly (inheritance contract)
    • IMediatorSendOnly declares neither QueryAsync nor StreamQueryAsync (write-only boundary enforcement via reflection)
    • Resolving IMediatorSendOnly from DI returns the same scoped instance as IMediator
    • A consumer typed to IMediatorSendOnly can invoke both SendAsync and PublishAsync
// Write-only consumer — compile-time CQRS enforcement
private sealed class WriteOnlyConsumer
{
    private readonly IMediatorSendOnly _mediator;

    public WriteOnlyConsumer(IMediatorSendOnly mediator) => _mediator = mediator;

    public async Task ExecuteAsync(CancellationToken cancellationToken = default)
    {
        _ = await _mediator.SendAsync<TestCommand, string>(new TestCommand(), cancellationToken);
        await _mediator.PublishAsync(new TestEvent(), cancellationToken);
    }
}

No production code changes required.

Copilot AI linked an issue Apr 16, 2026 that may be closed by this pull request
2 tasks
Copilot AI changed the title [WIP] Add unit tests for IMediatorSendOnly interface test: Unit tests for IMediatorSendOnly Apr 16, 2026
Copilot AI requested a review from samtrion April 16, 2026 06:50
@samtrion samtrion added state:ready for merge Indicates that a pull request has been reviewed and approved, and is ready to be merged into the mai type:feature Indicates a new feature or enhancement to be added. labels Apr 16, 2026
@samtrion
samtrion force-pushed the copilot/add-unit-tests-for-imediator-sendonly branch from 69f865d to 7ad14d4 Compare April 16, 2026 11:49
@codecov

codecov Bot commented Apr 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.19%. Comparing base (380596b) to head (7cbc378).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #403      +/-   ##
==========================================
+ Coverage   91.98%   92.19%   +0.20%     
==========================================
  Files         139      139              
  Lines        5266     5266              
  Branches      484      484              
==========================================
+ Hits         4844     4855      +11     
+ Misses        282      272      -10     
+ Partials      140      139       -1     

☔ 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.

@samtrion
samtrion marked this pull request as ready for review April 16, 2026 12:49
@samtrion
samtrion requested a review from a team as a code owner April 16, 2026 12:49
@samtrion
samtrion force-pushed the copilot/add-unit-tests-for-imediator-sendonly branch from 7ad14d4 to 7cbc378 Compare April 16, 2026 12:49
@samtrion
samtrion merged commit 2ef6ab6 into main Apr 16, 2026
11 checks passed
@samtrion
samtrion deleted the copilot/add-unit-tests-for-imediator-sendonly branch April 16, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:ready for merge Indicates that a pull request has been reviewed and approved, and is ready to be merged into the mai type:feature Indicates a new feature or enhancement to be added.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: Unit tests for IMediatorSendOnly

2 participants