public void ExitActionException(PassiveStateMachine <int, int> machine) { "establish an exit action throwing an exception".x(() => { var stateMachineDefinitionBuilder = new StateMachineDefinitionBuilder <int, int>(); stateMachineDefinitionBuilder .In(Values.Source) .ExecuteOnExit(() => throw Values.Exception) .On(Values.Event) .Goto(Values.Destination); machine = stateMachineDefinitionBuilder .WithInitialState(Values.Source) .Build() .CreatePassiveStateMachine(); machine.TransitionExceptionThrown += (s, e) => this.receivedTransitionExceptionEventArgs = e; }); "when executing the transition".x(() => { machine.Start(); machine.Fire(Values.Event, Values.Parameter); }); this.ItShouldHandleTransitionException(); }
public void StartingException(PassiveStateMachine <int, int> machine) { const int State = 1; "establish a entry action for the initial state that throws an exception".x(() => { var stateMachineDefinitionBuilder = new StateMachineDefinitionBuilder <int, int>(); stateMachineDefinitionBuilder .In(State) .ExecuteOnEntry(() => throw Values.Exception); machine = stateMachineDefinitionBuilder .WithInitialState(State) .Build() .CreatePassiveStateMachine(); machine.TransitionExceptionThrown += (s, e) => this.receivedTransitionExceptionEventArgs = e; }); "when starting the state machine".x(() => machine.Start()); "should catch exception and fire transition exception event".x(() => this.receivedTransitionExceptionEventArgs.Exception.Should().NotBeNull()); "should pass thrown exception to event arguments of transition exception event".x(() => this.receivedTransitionExceptionEventArgs.Exception.Should().BeSameAs(Values.Exception)); }
public void GuardException(AsyncPassiveStateMachine <int, int> machine) { "establish a guard throwing an exception".x(() => { var stateMachineDefinitionBuilder = new StateMachineDefinitionBuilder <int, int>(); stateMachineDefinitionBuilder .In(Values.Source) .On(Values.Event) .If((Func <Task <bool> >)(() => throw Values.Exception)) .Goto(Values.Destination); machine = stateMachineDefinitionBuilder .WithInitialState(Values.Source) .Build() .CreatePassiveStateMachine(); machine.TransitionExceptionThrown += (s, e) => this.receivedTransitionExceptionEventArgs = e; }); "when executing the transition".x(async() => { await machine.Start(); await machine.Fire(Values.Event, Values.Parameter); }); this.ItShouldHandleTransitionException(); }
public void Background() { this.receivedTransitionExceptionEventArgs = null; this.machine = new PassiveStateMachine <int, int>(); this.machine.TransitionExceptionThrown += (s, e) => this.receivedTransitionExceptionEventArgs = e; }
public void Background() { this.receivedTransitionExceptionEventArgs = null; this.machine = new PassiveStateMachine<int, int>(); this.machine.TransitionExceptionThrown += (s, e) => this.receivedTransitionExceptionEventArgs = e; }
private void StateMachineOnTransitionExceptionThrown(object sender, TransitionExceptionEventArgs <HueBridgeState, HueBridgeEvent> e) { Log.Error(e.Exception, "State Transition exception occured"); }