当前位置: 首页>>代码示例>>C#>>正文


C# StateMachine.AvailableStates方法代码示例

本文整理汇总了C#中StateMachine.AvailableStates方法的典型用法代码示例。如果您正苦于以下问题:C# StateMachine.AvailableStates方法的具体用法?C# StateMachine.AvailableStates怎么用?C# StateMachine.AvailableStates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StateMachine的用法示例。


在下文中一共展示了StateMachine.AvailableStates方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StateMachine_AvailableStates_ModelStateNotState_ThrowInvalidStateModel

 public void StateMachine_AvailableStates_ModelStateNotState_ThrowInvalidStateModel()
 {
     var model = new StubStateModel();
     var machine = new StateMachine<StubStateModel>();
     Assert.Throws<InvalidStateModelException>(() =>
         machine.AvailableStates(model));
 }
开发者ID:mmonteleone,项目名称:nate,代码行数:7,代码来源:StateMachineTests.cs

示例2: StateMachine_AvailableStates_ConcatsModelsTransWithGlobal_ReturnsDistinctStatesByName

        public void StateMachine_AvailableStates_ConcatsModelsTransWithGlobal_ReturnsDistinctStatesByName()
        {
            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 statetrans3 = new Transition<StubStateModel>(trigger2, state1, state3);
            var statetrans1 = new Transition<StubStateModel>(trigger1, state1, state2);
            var statetrans2 = new Transition<StubStateModel>(trigger1, 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.AvailableStates(model);

            Assert.Equal(3, result.Count());
            Assert.Equal(state1, result.ToList()[0]);
            Assert.Equal(state2, result.ToList()[1]);
            Assert.Equal(state3, result.ToList()[2]);
        }
开发者ID:mmonteleone,项目名称:nate,代码行数:33,代码来源:StateMachineTests.cs


注:本文中的StateMachine.AvailableStates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。