coreex-test-subscribe

Writes integration tests for CoreEx Subscribe hosts simulating broker message receipt.

28|8|Updated Feb 21, 2022
One-click install
npx skills add https://github.com/Avanade/CoreEx --skill coreex-test-subscribe-avanade
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: coreex-test-subscribe
Source: https://github.com/Avanade/CoreEx/tree/main/.github/skills/coreex-test-subscribe
Command: npx skills add https://github.com/Avanade/CoreEx --skill coreex-test-subscribe-avanade

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing integration tests for message subscribers often requires a live Service Bus connection and ad-hoc setup, making tests slow, fragile, and inconsistent. This Skill guides you through testing CoreEx Subscribe hosts against a real database, cache, and outbox by simulating broker message receipt in-process. ## Core Features & Use Cases - Simulated Message Receipt: Build an EventData, convert it to a ServiceBusReceivedMessage, and invoke ServiceBusSubscribedSubscriber.ReceiveAsync without any live broker connection. - Scenario-Matched Test Shapes: Provides distinct patterns for command subscribers (outcome plus outbox assertions), event-data-sync subscribers (local state assertions via the sync adapter), and event-business-process subscribers (downstream service and event assertions). - ErrorHandler and Plumbing Assertions: Assert handled-exception outcomes via EventSubscriberHandledException and verify unsubscribed subjects complete silently rather than being dead-lettered. - Use Case: After implementing a reservation-confirm command subscriber, generate a SubscriberTests partial class that seeds the database, simulates the command message, and asserts the expected outbox events and state changes. ## Quick Start Write an integration test for my reservation-confirm command subscriber that simulates the message receipt and asserts the resulting outbox events.

Frequently Asked Questions about coreex-test-subscribe

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

FAQPage Schema
How do I test a CoreEx message subscriber without a live Service Bus?▼

Build an EventData, convert it with Test.CreateCloudEventFrom(ed).ToServiceBusReceivedMessage(), resolve ServiceBusSubscribedSubscriber from DI, and call ReceiveAsync(sbm). This simulates broker receipt entirely in-process against the real Subscribe host.

How do I assert ErrorHandler outcomes in subscriber tests?▼

A handled exception surfaces as EventSubscriberHandledException on the failed result. Assert its ErrorHandling value (for example CompleteAsInformation) and inspect InnerException for the original exception type and error code.

What is the difference between command and event-data-sync subscriber tests?▼

Command tests assert the processing outcome plus any outbox events published as a result. Event-data-sync tests assert that local state reflects the incoming payload by querying the sync adapter or repository after receipt.

Does the Subscribe host test setup differ from API host tests?▼

The DB migrate/seed, FusionCache clearing, and outbox OneTimeSetUp foundation is shared with API tests. The only real difference is the trigger: a simulated message receipt instead of an HTTP call. Subscribe hosts do have FusionCache, so do not skip ClearFusionCacheAsync.

When should I not use this subscriber testing approach?▼

Do not use it for API host tests (use coreex-test-api), Outbox Relay host tests (use coreex-test-relay), or implementing the subscriber class itself (use coreex-subscriber). It also requires a configured messaging provider in the project.