Add read model state seeding to command scenarios#2315
Merged
Conversation
Command-scoped code (handlers, validators, Provide methods) can take a read model as a parameter; tests need to control what it contains. Add a Given builder on the command scenario that sets that up two ways: - Given.ForEventSource(id).Events(...) seeds events type-agnostically; any read model the command injects for that source is materialized from them through its own reducer or projection — no read model type is named. - Given.ForEventSource(id).ReadModel(instance) pins a specific instance. Read models resolve through a scenario IReadModels that projects seeded events on demand or returns a pinned instance, keyed by event source id; an unseeded source resolves to null so nullable read model parameters behave as they do in production. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Cover both seeding paths through the real command pipeline and reducer: - events seeding into a handler, a validator (allow and reject), a read model with no parameterless constructor, and one set of events feeding multiple read models - pinned instance into a handler, a Provide method, a validator (allow and reject), and a command targeting a different event source than the seeded one, which resolves to null Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the hand-mocked IReadModels guidance with the Given builder: seed read model state from events or pin an instance. Update the testing extension property tables and add a cross-link from the test-a-command recipe. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
NuGet packages for this PR, e.g. Cratis.Arc: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added
Given.ForEventSource(id).Events(...)materializes any read model the command injects for that source through its own reducer or projection, with no read model type named.Given.ForEventSource(id).ReadModel(instance).