public void TestFreeTransition() { var controller = new TestController(); var fsm = new AltoFSM <TestController>(controller); SetTransition(fsm); fsm.SetState <StandState>(); fsm.SendEvent(StateEvent.Talk); Assert.That(fsm.IsState <TalkState>, Is.True); fsm.SetState <WalkState>(); fsm.SendEvent(StateEvent.Talk); Assert.That(fsm.IsState <TalkState>, Is.True); }
public void TestGuard() { var controller = new TestController(); var fsm = new AltoFSM <TestController>(controller); SetTransition(fsm); fsm.SetState <StandState>(); fsm.SendEvent(StateEvent.Talk); Assert.That(fsm.IsState <TalkState>(), Is.True); fsm.SendEvent(StateEvent.Stand); Assert.That(fsm.IsState <StandState>(), Is.True); fsm.SetState <TalkState>(); controller.guardFromTalk = true; fsm.SendEvent(StateEvent.Stand); Assert.That(fsm.IsState <StandState>(), Is.False, "ガードされて遷移しない"); }
public void TestTransitionEventHandlers() { var controller = new TestController(); var fsm = new AltoFSM <TestController>(controller); SetTransition(fsm); fsm.SetState <StandState>(); fsm.SendEvent(StateEvent.Walk); fsm.Update(); fsm.SendEvent(StateEvent.Run); Assert.That(controller.sequence, Is.EqualTo("_out1_in2_up2_out2_in3")); }
public void TestBasic() { var controller = new TestController(); var fsm = new AltoFSM <TestController>(controller); SetTransition(fsm); fsm.SetState <StandState>(); Assert.That(fsm.currentState.GetType(), Is.EqualTo(typeof(StandState))); fsm.SendEvent(StateEvent.Run); fsm.SendEvent(StateEvent.Stand); fsm.SendEvent(StateEvent.Walk); Assert.That(fsm.currentState.GetType(), Is.EqualTo(typeof(WalkState))); Assert.That(fsm.IsState <WalkState>, Is.True); Assert.That(fsm.IsState <RunState>, Is.False); }