I'm finally starting to leverage the excellent Automatonymous components within MassTransit, and I'd like to TDD my way through my new state machines.
After reading over the MT docs here (http://masstransit-project.com/MassTransit/advanced/sagas/automatonymous.html) and spending some time Googling, I found unit tests right in the MT/Automatonymous Git repo that looked like the way to go:
- https://github.com/MassTransit/Automatonymous/blob/master/src/Automatonymous.Tests/Condition_Specs.cs#L21
In particular, the _machine.RaiseEvent(....)
method seemed to be exactly what I needed to be able to drive the state machine with test-provided stimuli.
Next, I went hunting for that overload... Turns out it's an extension method that appears to live here:
https://github.com/MassTransit/Automatonymous/blob/15e9181ed05e37ff71e85b514aafc351b1edf27f/src/Automatonymous/RaiseEventExtensions.tt
That's where I've gotten stuck. I'm not sure what the right way is to make use of these extension methods for testing? *.tt is a text generation template format... Are these installed as part of the nuget package? How do I gain access to the extensions? and/or more broadly, what is the recommended way to write unit tests for state machines inheriting from MassTransitStateMachine<T>
?
Follow-up question here: How to successfully drive a MassTransitStateMachine via the InMemoryTestHarness?