public void StartNotInOpenedOrUnlocked() { StateChart chart = GetChart(); Assert.IsFalse(chart.IsInState("opened")); Assert.IsFalse(chart.IsInState("unlocked")); }
public void StartInClosedAndLocked() { StateChart chart = GetChart(); Assert.IsTrue(chart.IsInState("closed")); Assert.IsTrue(chart.IsInState("locked")); }
public void TransitionsToAnotherState() { StateChart chart = new StateChart((builder) => { Action <string, Action> State = builder.State; State("State-1", () => { builder.Transition <SomeEvt>("State-1-2"); State("State-1-1", () => { State("State-1-1-1", () => { }); State("State-1-1-2", () => { }); }); State("State-1-2", () => { }); }); }); chart.Trigger(new SomeEvt()); chart.Tick(); Assert.IsTrue(chart.IsInState("State-1")); Assert.IsFalse(chart.IsInState("State-1-1")); Assert.IsFalse(chart.IsInState("State-1-1-1")); Assert.IsFalse(chart.IsInState("State-1-1-2")); Assert.IsTrue(chart.IsInState("State-1-2")); }
public void ProperlyQueuesEvents() { StateChart chart = GetChart2(); Assert.IsTrue(chart.IsInState("closed")); chart.Tick(); Assert.IsTrue(chart.IsInState("opened")); }
public void DoesNotTransitionIfGuardFnIsFalse() { StateChart chart = GetChart(); chart.Trigger(new Evt_DoorUnlock(false)); chart.Tick(); Assert.IsFalse(chart.IsInState("unlocked")); Assert.IsTrue(chart.IsInState("closed")); Assert.IsFalse(chart.IsInState("opened")); Assert.IsTrue(chart.IsInState("locked")); }
public void DoesNotTransitionIfNoTransitionHandlerExistsForCongiuration() { StateChart chart = GetChart(); chart.Trigger(new Evt_DoorOpen()); chart.Tick(); Assert.IsFalse(chart.IsInState("opened")); Assert.IsTrue(chart.IsInState("closed")); Assert.IsTrue(chart.IsInState("locked")); Assert.IsFalse(chart.IsInState("unlocked")); }
public void MovesToUnlockedFromClosedWithUnlockEvent() { StateChart chart = GetChart(); chart.Trigger(new Evt_DoorUnlock()); chart.Tick(); Assert.IsTrue(chart.IsInState("unlocked")); Assert.IsTrue(chart.IsInState("closed")); Assert.IsFalse(chart.IsInState("opened")); Assert.IsFalse(chart.IsInState("locked")); }
public void StateChart_SpecSimplePasses() { StateChart chart = new StateChart((builder) => { Action <string, Action> State = builder.State; State("State-1", () => { State("State-1-1", () => { State("State-1-1-1", () => { }); State("State-1-1-2", () => { }); }); State("State-1-2", () => { }); }); }); Assert.IsTrue(chart.IsInState("State-1")); Assert.IsTrue(chart.IsInState("State-1-1")); Assert.IsTrue(chart.IsInState("State-1-1-1")); Assert.IsFalse(chart.IsInState("State-1-1-2")); Assert.IsFalse(chart.IsInState("State-1-2")); }
public void MovesFromClosedAndUnlockedToOpenedAndBackToClosedLocked() { StateChart chart = GetChart(); chart.Trigger(new Evt_DoorUnlock()); chart.Trigger(new Evt_DoorOpen()); chart.Tick(); Assert.IsTrue(chart.IsInState("opened")); Assert.IsFalse(chart.IsInState("closed")); Assert.IsFalse(chart.IsInState("locked")); Assert.IsFalse(chart.IsInState("unlocked")); chart.Trigger(new Evt_DoorClose()); chart.Tick(); Assert.IsFalse(chart.IsInState("opened")); Assert.IsTrue(chart.IsInState("closed")); Assert.IsFalse(chart.IsInState("locked")); Assert.IsTrue(chart.IsInState("unlocked")); }