public void TestInitialize() { service = Mock.Of <IMovieBookingService>(); commonWorkflowService = Mock.Of <ICommonWorkflowService>(); sut = new MovieBookingWorkflow(service, commonWorkflowService); }
public MovieBookingWorkflow(IMovieBookingService service, ICommonWorkflowService commonWorkflowService) : base(commonWorkflowService) { this.movieBookingService = service; State(() => WaitingForCinemaSelection); State(() => WaitingForMovieSelection); State(() => WaitingForSlotSelection); State(() => Completed); Event(() => ValidResponse); Event(() => MoreSlotsRequested); //Ideally we would have this in the BaseStateMachine, however it needs to be executed after all of the States have been setup //This could be fixed by using an AbstractFactory to create an instance of the actual workflow classes and force a call //to a method that executes this: http://stackoverflow.com/a/2747280 DuringAny(When(InvalidResponse).Then(wf => SendUnknownResponse(wf))); Initially(When(Start).Then((wf, data) => SendListOfCinemas(wf, data)).TransitionTo(WaitingForCinemaSelection)); During(WaitingForCinemaSelection, When(SMSReceived).Then((wf, data) => ProcessCinemaSelection(wf, data)), When(ValidResponse).Then(wf => SendListOfMovies(wf)).TransitionTo(WaitingForMovieSelection) ); During(WaitingForMovieSelection, When(SMSReceived).Then((wf, data) => ProcessMovieSelection(wf, data)), When(ValidResponse).Then(wf => SendMovieSlots(wf)).TransitionTo(WaitingForSlotSelection) ); During(WaitingForSlotSelection, When(SMSReceived, (msg) => !msg.Equals("MORE")).Then((wf, data) => ProcessSlotSelection(wf, data)), When(SMSReceived, (msg) => msg.Equals("MORE")).Then((wf) => this.RaiseEvent(wf, MoreSlotsRequested)), When(MoreSlotsRequested).Then((wf) => SendMovieSlots(wf)), When(ValidResponse).Then(wf => SendConfirmationCode(wf)).Finalize() ); }
public void TestInitialize() { service = Mock.Of<IMovieBookingService>(); commonWorkflowService = Mock.Of<ICommonWorkflowService>(); sut = new MovieBookingWorkflow(service, commonWorkflowService); }