public void Transition_NodeToSubFSM_WhenPredicateIsTrue() { var n = 0; var fsm = new FSM(); var subFSMA = new SubFSM(); var subFSMB = new SubFSM(); var stateA = new StateA(); var stateB = new StateB(); var stateC = new StateC(); var stateD = new StateD(); fsm.AddTransition(stateA, subFSMA, () => n == 1); subFSMA.AddTransition(stateB, subFSMB, () => n == 2); subFSMB.AddTransition(stateC, stateD, () => n == 3); fsm.Start(); n = 1; fsm.Update(); n = 2; fsm.Update(); n = 3; fsm.Update(); Assert.IsTrue(fsm.CurrentNode == subFSMA && subFSMA.CurrentNode == subFSMB && subFSMB.CurrentNode == stateD); }
public void AddNode_NotAllowIntersectSubFSM() { var subFSMA = new SubFSM(); var subFSMB = new SubFSM(); var stateA = new StateA(); subFSMA.AddNode(stateA); subFSMB.AddNode(stateA); subFSMB.AddNode(subFSMA); Assert.IsTrue(!subFSMB.Contains(subFSMA)); }
public void AddNode_NotAllowIntersectSubFSM() { var fsm = new FSM(); var subFSM = new SubFSM(); var stateA = new StateA(); subFSM.AddNode(stateA); fsm.AddNode(stateA); fsm.AddNode(subFSM); Assert.IsTrue(!fsm.Contains(subFSM)); }
public void AddNode_NotAllowOwnerNode() { var fsm = new FSM(); var subFSM = new SubFSM(); var stateA = new StateA(); fsm.AddNode(stateA); fsm.AddNode(subFSM); subFSM.AddNode(stateA); Assert.IsTrue(!subFSM.Contains(stateA)); }
public void RemoveNode_FromSubFSM() { var fsm = new FSM(); var subFSM = new SubFSM(); var stateA = new StateA(); var stateB = new StateB(); var stateD = new StateD(); subFSM.AddNode(stateD); fsm.AddTransition(stateA, stateB, () => true); fsm.AddTransition(stateB, subFSM, () => true); fsm.RemoveNode(stateD); Assert.IsTrue(!fsm.Contains(stateD)); }
public void Transition_NodeToSubFSM_WhenPredicateIsTrue() { var n = 0; var fsm = new FSM(); var subFSM = new SubFSM(); var stateA = new StateA(); var stateB = new StateB(); var stateC = new StateC(); subFSM.AddTransition(stateB, stateC, () => n == 2); fsm.AddTransition(stateA, subFSM, () => n == 1); fsm.Start(); n = 1; fsm.Update(); n = 2; fsm.Update(); Assert.IsTrue(fsm.CurrentNode == subFSM && subFSM.CurrentNode == stateC); }