public void SwitchOff(LightSwitchContext context) { Console.WriteLine("It's already dark"); //TODO context.MoveTo(_lightSwitchStates.SwitchedOff()); //transition to self. What happens? }
public void OnEnter(LightSwitchContext context) { _light.PowerDown(); }
public void OnEnter(LightSwitchContext context) { _light.PowerUp(); //should this be inside context or not? context.RegisterSwitchOn(); }
public void SwitchOn(LightSwitchContext context) { context.MoveTo(_lightSwitchStates.SwitchedOn()); }
public LightSwitchState Initial(LightSwitchContext context) { return(SwitchedOff(context)); }
public LightSwitchState SwitchedOn(LightSwitchContext context) { return(new SwitchedOnState(this, _light, context)); }
public SwitchedOnState(LightSwitchStates lightSwitchStates, Light light, LightSwitchContext context) { _lightSwitchStates = lightSwitchStates; _light = light; _context = context; }
public void SwitchOn(LightSwitchContext context) { Console.WriteLine("already switched on"); //what if I move to current state instead? }
//etc. etc. private static void AssertMachineIsIn(LightSwitchState nextState, LightSwitchContext machine) { nextState.Received(1).SwitchOn(machine); }