aibdd.auto.csharp.it.handlers.aggregate-then

Verify aggregate final states in Gherkin tests via EF Core DbContext queries.

1|Updated Mar 6, 2026
One-click install
npx skills add https://github.com/zenbuapps/zenbu-powers --skill aibdd-auto-csharp-it-handlers-aggregate-then
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: aibdd.auto.csharp.it.handlers.aggregate-then
Source: https://github.com/zenbuapps/zenbu-powers/tree/main/skills/aibdd.auto.csharp.it.handlers.aggregate-then
Command: npx skills add https://github.com/zenbuapps/zenbu-powers --skill aibdd-auto-csharp-it-handlers-aggregate-then

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

在 Gherkin 測試中驗證 Aggregate 的最終狀態,需準確對資料庫的持久化結果進行驗證。本規範提供使用 EF Core DbContext 查詢與比對持久狀態的實作指引。

Core Features & Use Cases

  • 透過 EF Core DbContext 與複合主鍵查詢,驗證資料庫的持久化結果是否符合 Gherkin 描述。
  • 提供 ChangeTracker.Clear() 以避免快取影響驗證,並與 ReadModel-Then 進行區別。
  • 支援中文狀態映射到 C# enum,確保狀態欄位一致性。

Quick Start

Inject AppDbContext, clear the ChangeTracker, and query the database to verify the aggregate's final state.

Frequently Asked Questions about aibdd.auto.csharp.it.handlers.aggregate-then

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

FAQPage Schema
How do I verify aggregate final state in Gherkin integration tests using EF Core?

Verifying aggregate final state in Gherkin integration tests involves injecting AppDbContext, clearing the ChangeTracker to avoid cache interference, and querying PostgreSQL via EF Core composite-key lookups. This ensures persisted data matches domain expectations in .NET 8+ integration testing scenarios.

Why does EF Core ChangeTracker return stale data during SpecFlow integration testing?

EF Core ChangeTracker returns stale data during SpecFlow integration testing because cached entities bypass database queries. Calling ChangeTracker.Clear() before asserting aggregate final state forces DbContext to query PostgreSQL directly, ensuring Gherkin tests validate actual persisted database outcomes rather than in-memory cached domain objects.

What is the difference between asserting aggregate state and ReadModel in BDD tests?

Asserting aggregate state queries the database directly via EF Core DbContext to verify persisted domain entity outcomes, while ReadModel verification checks projected query models. Aggregate-then testing clears the ChangeTracker and uses composite-key lookups to ensure the data layer matches Gherkin domain expectations accurately without cache interference.

Can I map Chinese Gherkin step text to C# enum states for PostgreSQL integration testing?

Yes, Chinese Gherkin step text can be mapped to C# enum states for PostgreSQL integration testing. This Skill supports language mapping between domain states described in Gherkin scenarios and C# enums, ensuring status field consistency when verifying aggregate final state directly from the database through EF Core DbContext.

Does this aggregate state verification approach support composite-key lookups with EF Core?

This aggregate state verification approach supports composite-key lookups with EF Core. It queries PostgreSQL through AppDbContext using composite primary keys to retrieve persisted entities, ensuring accurate verification of aggregate final state in Gherkin integration testing scenarios for .NET 8+ applications without ChangeTracker cache interference.

When should I clear ChangeTracker in EF Core integration tests for BDD scenarios?

You should clear ChangeTracker in EF Core integration tests for BDD scenarios immediately before querying aggregate final state from the database. Calling ChangeTracker.Clear() prevents cached entities from interfering with Gherkin assertions, ensuring the test verifies actual PostgreSQL persistence outcomes rather than stale in-memory domain objects.