aggregate-testing

Generate tests for event-sourced aggregates using fakers and assertion extensions.

4|1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill aggregate-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: aggregate-testing
Source: https://github.com/FaysilAlshareef/dotnet-ai-kit/tree/main/skills/microservice/command/aggregate-testing
Command: npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill aggregate-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides patterns and best practices to reliably test event-sourced aggregates in .NET projects, reducing brittle tests and manual setup when events have private constructors or complex nested data.

Core Features & Use Cases

  • Constructor bypassing: Use a CustomConstructorFaker pattern to instantiate event and data types without invoking primary constructors.
  • Deterministic fakers: Create event and event-data fakers that populate metadata and nested properties for repeatable test scenarios.
  • Assertion extensions and integration helpers: Field-by-field assertions between protobuf requests and persisted events, plus DbContextHelper and GrpcClientHelper to validate database persistence and outbox messaging in integration tests.
  • Use Case: Add comprehensive tests for create and update commands that verify event sequences, outbox messages, and correct exception handling for duplicates or invalid operations.

Quick Start

Create an integration test that uses a CustomConstructorFaker to generate an OrderCreated event, sends the corresponding gRPC command via GrpcClientHelper, and asserts persisted events and outbox messages with the provided assertion extensions.

Frequently Asked Questions about aggregate-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test event-sourced aggregates in .NET when events have private constructors?

You can test event-sourced aggregates with private constructors by using a CustomConstructorFaker pattern to instantiate event and data types without invoking primary constructors, enabling reliable test setup for complex nested data.

What is the best way to verify gRPC commands against persisted events in .NET integration tests?

The best way to verify gRPC commands against persisted events is using assertion extensions for field-by-field comparisons between protobuf requests and stored event data, combined with GrpcClientHelper to send commands and DbContextHelper to validate database persistence.

How do I validate outbox messages and database persistence in .NET microservice integration tests?

You validate outbox messages and database persistence in .NET integration tests by utilizing DbContextHelper and GrpcClientHelper for end-to-end verification, ensuring that command handlers correctly persist events and trigger outbox messaging.

Can I use fakers to generate deterministic test data for event-sourcing scenarios with nested properties?

Yes, you can use deterministic fakers to populate metadata and nested properties for event and event-data types, creating repeatable test scenarios that reliably validate create and update commands in event-sourced .NET aggregates.

Does this testing approach support verifying exception handling for duplicate or invalid operations in command handlers?

Yes, this testing approach supports verifying exception handling for duplicates or invalid operations by generating comprehensive tests for create and update commands that assert correct exception behavior alongside event sequences and outbox messages.