Example #1
0
 public void SwitchOff(LightSwitchContext context)
 {
     Console.WriteLine("It's already dark");
     //TODO context.MoveTo(_lightSwitchStates.SwitchedOff()); //transition to self. What happens?
 }
Example #2
0
 public void OnEnter(LightSwitchContext context)
 {
     _light.PowerDown();
 }
Example #3
0
 public void OnEnter(LightSwitchContext context)
 {
     _light.PowerUp(); //should this be inside context or not?
     context.RegisterSwitchOn();
 }
Example #4
0
 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));
 }
Example #7
0
 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);
        }