本文整理汇总了C#中StateMachine.AvailableTriggers方法的典型用法代码示例。如果您正苦于以下问题:C# StateMachine.AvailableTriggers方法的具体用法?C# StateMachine.AvailableTriggers怎么用?C# StateMachine.AvailableTriggers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateMachine
的用法示例。
在下文中一共展示了StateMachine.AvailableTriggers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StateMachine_AvailableTriggers_ModelStateNotState_ThrowInvalidStateModel
public void StateMachine_AvailableTriggers_ModelStateNotState_ThrowInvalidStateModel()
{
var model = new StubStateModel();
var machine = new StateMachine<StubStateModel>();
Assert.Throws<InvalidStateModelException>(() =>
machine.AvailableTriggers(model));
}
示例2: StateMachine_AvailableTriggers_ConcatsModelsTransWithGlobal_ReturnsDistinctTrigsByName
public void StateMachine_AvailableTriggers_ConcatsModelsTransWithGlobal_ReturnsDistinctTrigsByName()
{
var model = new StubStateModel();
var machine = new StateMachine<StubStateModel>();
var trigger1 = new Trigger("t1");
var trigger2 = new Trigger("t2");
var state1 = new State<StubStateModel>("s1");
var state2 = new State<StubStateModel>("s2");
var state3 = new State<StubStateModel>("s3");
var state4 = new State<StubStateModel>("s4");
var statetrans1 = new Transition<StubStateModel>(trigger1, state1, state2);
var statetrans2 = new Transition<StubStateModel>(trigger1, state1, state3);
var statetrans3 = new Transition<StubStateModel>(trigger2, state1, state3);
var globaltrans1 = new Transition<StubStateModel>(trigger2, null, state1);
machine.AddGlobalTransition(globaltrans1);
state1.AddTransition(statetrans1);
state1.AddTransition(statetrans2);
state1.AddTransition(statetrans3);
model.CurrentState = state1;
var result = machine.AvailableTriggers(model);
Assert.Equal(2, result.Count());
Assert.Equal(trigger1, result.ToList()[0]);
Assert.Equal(trigger2, result.ToList()[1]);
}