Ncqrs: How to store events as part of test set-up

115 views Asked by At

How do I store events as part of setting up my tests?

Currently I'm initializing application state by sending commands like this:

Given some commands were sent
When sending another command
Then some events should have been published

I'm using ICommandService.Execute() to send the Commands in the Given and When parts.

Since commands can be rejected by the domain, I wouldn't want to rely on them. I'd rather set up my application state by simulating events like this:

Given _some events_ occurred
When sending a command
Then some events should have been published

How do I push the events from Given into the event store so that they can be replayed during handling the "When" part?

Thanks

Dennis

1

There are 1 answers

0
Dennis Traub On BEST ANSWER

Have been given the answer on the mailing list and will add this for further reference:

I was using an old version of Ncqrs. The current version exposes Ncqrs.Eventing.Storage.IEventStore.Store() which takes an event stream and can be uses during test set-up just as needed.