public void It_should_restart_nested_fsm_on_rerun() { var nestedFsm = new FsmBuilder() .Default(StateId.A) .State(StateId.A, (state) => { state.SetTransition("next", StateId.B); state.Update((action) => action.Transition("next")); }) .State(StateId.B, (state) => { state.FsmExit(); }) .Build(); var fsm = new FsmBuilder() .Default(StateId.A) .State(StateId.A, (state) => { state.SetTransition("next", StateId.B); state.RunFsm("next", nestedFsm); }) .State(StateId.B, (state) => { state.RunFsm("none", nestedFsm); }) .Build(); fsm.Tick(); fsm.Tick(); Assert.AreEqual(StateId.A, nestedFsm.CurrentState.Id); }
public void It_should_call_Enter_on_nested_FSM_when_ticked() { var stateEnter = false; var nestedFsm = new FsmBuilder() .Default(StateId.A) .State(StateId.A, (state) => { state.Enter((action) => stateEnter = true); }) .Build(); var fsm = new FsmBuilder() .Default(StateId.A) .State(StateId.A, (state) => { state.RunFsm("a", nestedFsm); }) .Build(); fsm.Tick(); Assert.IsTrue(stateEnter); }
public void Should_not_crash_with_nothing_built() { var fsm = new FsmBuilder().Build(); fsm.Tick(); }