Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manually build aggregate state for unit testing #79

Open
developmentalmadness opened this issue Aug 22, 2016 · 5 comments
Open

manually build aggregate state for unit testing #79

developmentalmadness opened this issue Aug 22, 2016 · 5 comments

Comments

@developmentalmadness
Copy link

Is there a way to manually set the state of an aggregate instance? Currently I am defining and handling all the commands it takes to put an aggregate instance in a specific state. Instead is there a way to just assume it correctly arrived at that state (like passing in a snapshot) and then handle the event?

@adrai
Copy link
Contributor

adrai commented Aug 22, 2016

In theory yes

@adrai
Copy link
Contributor

adrai commented Aug 22, 2016

But it's a hack and I would not recommend it

@adrai
Copy link
Contributor

adrai commented Aug 22, 2016

You could try to set modelInitValues before handling a command...

something like require('./myaggr').modelInitValues = {};

@developmentalmadness
Copy link
Author

maybe I'm thinking of this in the wrong way. How would you recommend setting up aggregates for testing individual commands? Is there a reference sample somewhere I could look at? Or is the accepted method just handling an entire list of events for a given scenario?

@adrai
Copy link
Contributor

adrai commented Aug 23, 2016

I do it always, like the integrationTests: send a couple of commands...

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

No branches or pull requests

2 participants