Skip to content

feat: Introduce NetEvolve.Pulse.Testing — FakeMediator for unit testing#157

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-fake-mediator-nuget-package
Draft

feat: Introduce NetEvolve.Pulse.Testing — FakeMediator for unit testing#157
Copilot wants to merge 2 commits intomainfrom
copilot/add-fake-mediator-nuget-package

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

Lightweight fake IMediator implementation for unit testing without a DI container.

New package: NetEvolve.Pulse.Testing

  • FakeMediator : IMediator — thread-safe (backed by ConcurrentDictionary), zero dependencies beyond NetEvolve.Pulse.Extensibility
  • RequestSetup<TResponse> — fluent builder returned by SetupCommand / SetupQuery with .Returns(value) and .Throws(ex) / .Throws<T>()
  • SetupEvent<TEvent>() — captures published events for later retrieval
  • Verify<T>(int times) — asserts invocation count, throws descriptive InvalidOperationException on mismatch
  • GetPublishedEvents<TEvent>() — returns captured events in publication order
  • Unconfigured commands/queries throw InvalidOperationException with actionable message

Tests

  • 21 tests in NetEvolve.Pulse.Testing.Tests.Unit covering all public API surface across net8.0, net9.0, net10.0

Usage

var mediator = new FakeMediator();

mediator.SetupCommand<CreateOrderCommand, OrderResult>()
    .Returns(new OrderResult { Id = "123" });

mediator.SetupEvent<OrderCreatedEvent>();

// exercise code under test...

mediator.Verify<CreateOrderCommand>(times: 1);
var events = mediator.GetPublishedEvents<OrderCreatedEvent>();

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

Introduces a new testing support package that provides a lightweight
FakeMediator implementation for unit testing scenarios.

- FakeMediator implements IMediator fully
- SetupCommand/SetupQuery with fluent Returns()/Throws() builder
- SetupEvent for event capture
- Verify<T>(times) for invocation count assertions
- GetPublishedEvents<T>() for captured events
- Thread-safe implementation using ConcurrentDictionary
- 21 comprehensive unit tests across net8.0/net9.0/net10.0

Agent-Logs-Url: https://github.com/dailydevops/pulse/sessions/c0a8ee2f-68c0-4dca-b307-12af53b9a5f9

Co-authored-by: samtrion <3283596+samtrion@users.noreply.github.com>
Copilot AI changed the title [WIP] Add NetEvolve.Pulse.Testing with FakeMediator for unit testing feat: Introduce NetEvolve.Pulse.Testing — FakeMediator for unit testing Mar 28, 2026
Copilot AI requested a review from samtrion March 28, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Introduce NetEvolve.Pulse.Testing — FakeMediator for unit testing

2 participants