本文整理汇总了C#中FSM.Step方法的典型用法代码示例。如果您正苦于以下问题:C# FSM.Step方法的具体用法?C# FSM.Step怎么用?C# FSM.Step使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSM
的用法示例。
在下文中一共展示了FSM.Step方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldExecuteOnExitWhenLeavingCurrentState
public void ShouldExecuteOnExitWhenLeavingCurrentState()
{
var was_here = false;
var fsm = new FSM<string>();
fsm.AddState("start_here", null, input => was_here = true);
fsm.AddState("exit_here");
fsm.AddTransition("start_here", "exit_here", input => true);
fsm.Step();
Assert.That(was_here, Is.True);
}
示例2: ShouldExecuteOnEnterWhenEnteringNextState
public void ShouldExecuteOnEnterWhenEnteringNextState()
{
var exit_here = false;
var fsm = new FSM<string>();
fsm.AddState("start_here");
fsm.AddState("exit_here", input => exit_here = true);
fsm.AddTransition("start_here", "exit_here", input => true);
fsm.Step();
Assert.That(exit_here, Is.True);
}
示例3: ShouldEvaluateTransitionCondition
public void ShouldEvaluateTransitionCondition()
{
var conditionEvaluated = false;
var fsm = new FSM<string>();
fsm.AddState("initial");
fsm.AddState("end");
fsm.AddTransition("initial", "end", input => { conditionEvaluated = true; return false; });
fsm.Step();
Assert.That(conditionEvaluated, Is.True);
}
示例4: ShouldEvaluateMultipleTransitionsUntilConditionIsMet
public void ShouldEvaluateMultipleTransitionsUntilConditionIsMet()
{
var fsm = new FSM<string>();
fsm.AddState("one");
fsm.AddState("two");
fsm.AddState("three");
fsm.AddTransition("one", "two", input => false);
fsm.AddTransition("one", "three", input => true);
fsm.Step();
Assert.That(fsm.CurrentState, Is.EqualTo("three"));
}
示例5: ShouldFollowTransitionIfConditionIsMet
public void ShouldFollowTransitionIfConditionIsMet()
{
var fsm = new FSM<string>();
fsm.AddState("start");
fsm.AddState("exit");
fsm.AddTransition("start", "exit", input => true);
fsm.Step();
Assert.That(fsm.CurrentState, Is.EqualTo("exit"));
}
示例6: ShouldExecuteTransitionAction
public void ShouldExecuteTransitionAction()
{
var action = false;
var fsm = new FSM<string>();
fsm.AddState("first");
fsm.AddState("second");
fsm.AddTransition("first", "second", input => true, input => action = true);
fsm.Step();
Assert.That(action, Is.True);
}
示例7: ShouldNotExecuteOnEnterWhenInInitialState
public void ShouldNotExecuteOnEnterWhenInInitialState()
{
var fsm = new FSM<string>();
var onEnter = false;
fsm.AddState("initial", input => onEnter = true);
fsm.Step();
Assert.That(onEnter, Is.False);
}