Sample-ShoppingWeb icon indicating copy to clipboard operation
Sample-ShoppingWeb copied to clipboard

Add unittests to the sample

Open SierraNL opened this issue 6 years ago • 3 comments

It would be very useful to have unittests for the sample.

I for example used the shoppingcart saga example to create my own saga. And like every good programmer ;) I would like to create unittests for it. But there are none in the example. Neither are there in the MassTransit sources or in the Automatonymous project.

And from the looks of it, unittesting a saga isn't very trivial, and I would need some harness to test it.

SierraNL avatar May 25 '18 08:05 SierraNL

There are dozens of unit tests on the state machine sagas in the MassTransit repository:

https://github.com/MassTransit/MassTransit/tree/develop/src/MassTransit.AutomatonymousIntegration.Tests

phatboyg avatar May 25 '18 15:05 phatboyg

@phatboyg I think this is a wrong answer, as the unit tests at the link you provided test Automatonymous functionality, they do not provide an example on how to unit test your own Automatonymous state machine. I'd actually need the same: unit testing my saga in an MsTest environment, have been searching the web for quite a while now, but didn't come up with anything :-(

balintn22 avatar Oct 14 '19 15:10 balintn22

Implemented an example here: https://github.com/balintn22/AutomatonymousTestExample

balintn22 avatar Oct 15 '19 11:10 balintn22