MassTransit / Sample-ShoppingWeb

A web site with a simulated cart, using a saga to track cart expiration via Quartz
Apache License 2.0
80 stars 38 forks source link

Add unittests to the sample #9

Open SierraNL opened 6 years ago

SierraNL commented 6 years ago

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.

phatboyg commented 6 years ago

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

balintn22 commented 4 years ago

@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 commented 4 years ago

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