示例#1
0
                public void It_should_restart_nested_fsm_on_rerun()
                {
                    var nestedFsm = new FsmBuilder()
                                    .Default(StateId.A)
                                    .State(StateId.A, (state) => {
                        state.SetTransition("next", StateId.B);
                        state.Update((action) => action.Transition("next"));
                    })
                                    .State(StateId.B, (state) => {
                        state.FsmExit();
                    })
                                    .Build();

                    var fsm = new FsmBuilder()
                              .Default(StateId.A)
                              .State(StateId.A, (state) => {
                        state.SetTransition("next", StateId.B);
                        state.RunFsm("next", nestedFsm);
                    })
                              .State(StateId.B, (state) => {
                        state.RunFsm("none", nestedFsm);
                    })
                              .Build();

                    fsm.Tick();
                    fsm.Tick();

                    Assert.AreEqual(StateId.A, nestedFsm.CurrentState.Id);
                }
示例#2
0
                public void It_should_call_Enter_on_nested_FSM_when_ticked()
                {
                    var stateEnter = false;
                    var nestedFsm  = new FsmBuilder()
                                     .Default(StateId.A)
                                     .State(StateId.A, (state) => {
                        state.Enter((action) => stateEnter = true);
                    })
                                     .Build();

                    var fsm = new FsmBuilder()
                              .Default(StateId.A)
                              .State(StateId.A, (state) => {
                        state.RunFsm("a", nestedFsm);
                    })
                              .Build();

                    fsm.Tick();

                    Assert.IsTrue(stateEnter);
                }
示例#3
0
            public void Should_not_crash_with_nothing_built()
            {
                var fsm = new FsmBuilder().Build();

                fsm.Tick();
            }