public void GoToStateTest() { var ctx = new TestStateCtx(); var stateMachine = new StateMachine <TestState, TestEvent, TestStateCtx, string>(); stateMachine.Add(new StateA()); stateMachine.RegisterCtx(ctx); ctx.Add(TestEvent.E, "hi"); Thread.Sleep(5); Assert.AreEqual(TestState.B, ctx.CurrentState); }
public void DeferTest() { var ctx = new TestStateCtx(); var stateMachine = new StateMachine <TestState, TestEvent, TestStateCtx, string>(); stateMachine.Add(new StateA()); stateMachine.Add(new StateB()); stateMachine.RegisterCtx(ctx); ctx.Add(TestEvent.G, "hel"); ctx.Add(TestEvent.E, "hi"); Thread.Sleep(15); Assert.AreEqual(TestState.B, ctx.CurrentState); Assert.IsTrue(ctx.RanG); }