protected override void Context() { stateMachine = new StateMachine(); stateMachine.AddState(); stateMachine.AddState(); stateMachine.CreatePathFrom.State(1).To.State(2); stateMachine.Start(); rootContext = new MainContextStub(); sut = new MainModule(rootContext); }
private void Init() { _sm = new StateMachine(); _sm.AddState(s => s.Name = "UseSword"); _sm.AddState(s => s.Name = "LoseSword"); _sm.CreatePathFrom.State("UseSword").To.State("LoseSword"); // when starting the state machine, the first state declared // is automatically loaded _sm.Start(); var samuraiContext = new SamuraiContext(); _mainModule = new MainModule(samuraiContext); var swordContext = new UseSwordContext(_sm, _sm.GetState("UseSword")); samuraiContext.AddChild(swordContext); var bareHandsContext = new UseBareHandsContext(_sm, _sm.GetState("LoseSword")); samuraiContext.AddChild(bareHandsContext); }