how to get advantage of stateless framework
Nicholas Blumhardt wrote good post about stateless framework.
I like BugTrackerExample which they have in source code.
So your machine would probably look like this:
class Generator
{
private readonly StateMachine state;
public Generator()
{
state = new StateMachine(State.Stopped);
// your definition of states ...
state.Configure(State.GenerateMachineData)
.OnEntry(() => { Generate(); })
.Permit(Trigger.Failed, State.Error)
.Permit(Trigger.Succeed, State.Finished);
// ...
}
public void Succeed()
{
state.Fire(Trigger.Succeed);
}
public void Fail()
{
state.Fire(Trigger.Fail);
}
public void Generate()
{
// ...
}
}
In this case tests shouldn't be problem.
If you need further separation you can use event, delegate or strategy pattern instead of Generate
method.