public void US7_When_I_open_the_door_twice(IMicrowaveOvenControler ctrl, IMicrowaveOvenHWEx hw)
 {
     using (var ctx = new MicrowaveTestSetup(ctrl, hw))
     {
         // simulate door open twice - does it make any sense?
         ctx.Ui.OpenDoor();
         ctx.Ui.OpenDoor();
     }
 }
        public void US1_When_I_open_door_Light_is_on(IMicrowaveOvenControler ctrl, IMicrowaveOvenHWEx hw)
        {
            using (var ctx = new MicrowaveTestSetup(ctrl, hw))
            {
                // simulate door open
                ctx.Ui.OpenDoor();

                Assert.IsTrue(ctx.Hw.LightOn, "ensure the light is on after door closing");
            }
        }
示例#3
0
 public void Dispose()
 {
     if (Ctrl is IDisposable ctrlDisp)
     {
         ctrlDisp.Dispose();
     }
     Ctrl = null;
     if (Hw is IDisposable hwDisp)
     {
         hwDisp.Dispose();
     }
     Hw = null;
 }
示例#4
0
        public MicrowaveTestSetup(IMicrowaveOvenControler ctrl, IMicrowaveOvenHWEx hw)
        {
            Ctrl = ctrl;
            Hw   = hw;

            Hw.Initialize();
            Ctrl.Initialize(Hw);

            // ensure the heater is off and the door closed - default initial state
            Assert.IsFalse(Hw.HeaterOn);
            Assert.IsFalse(Hw.DoorOpen);
            Assert.IsFalse(Hw.LightOn);
        }
示例#5
0
        public void Initialize(IMicrowaveOvenHWEx hw)
        {
            _hw = hw;

            // ensure initial state
            _hw.TurnOffHeater();
            _hw.TurnOffLight();

            InternalInitialize();

            // subscribe HW events
            _hw.DoorOpenChanged    += HwOnDoorOpenChanged;
            _hw.StartButtonPressed += HwOnStartButtonPressed;
            _initialized            = true;
        }
        public void US3_When_I_open_door_heater_stops_if_running_ensure_total_time(IMicrowaveOvenControler ctrl, IMicrowaveOvenHWEx hw)
        {
            using (var ctx = new MicrowaveTestSetup(ctrl, hw))
            {
                // simulate press start button - start heating
                ctx.Ui.PressStartButton();

                Assert.IsTrue(ctx.Hw.HeaterOn, "ensure the heater has been started after 'PressStartButton'");

                // simulate door open
                ctx.Ui.OpenDoor();

                // simulate time elapsed - should not change enything
                SimulateTimeElapse(ctx.Ctrl, 60);

                // simulate door close
                ctx.Ui.CloseDoor();

                SimulateTimeElapse(ctx.Ctrl, 59);

                Assert.IsTrue(ctx.Hw.HeaterOn, "ensure the heater is still running");
                Assert.IsFalse(ctx.Hw.LightOn, "ensure if light is of after closing the door");
            }
        }
        public void US3_When_I_open_door_heater_stops_if_running(IMicrowaveOvenControler ctrl, IMicrowaveOvenHWEx hw)
        {
            using (var ctx = new MicrowaveTestSetup(ctrl, hw))
            {
                // simulate press start button - start heating
                ctx.Ui.PressStartButton();

                Assert.IsTrue(ctx.Hw.HeaterOn, "ensure the heater has been started after 'PressStartButton'");

                // simulate door open
                ctx.Ui.OpenDoor();

                Assert.IsFalse(ctx.Hw.HeaterOn, "ensure the heater has been stopped after opening the door");
                Assert.IsTrue(ctx.Hw.LightOn, "ensure if light is on after opening the door");
            }
        }
        public void US2_When_I_close_door_Light_turns_off(IMicrowaveOvenControler ctrl, IMicrowaveOvenHWEx hw)
        {
            using (var ctx = new MicrowaveTestSetup(ctrl, hw))
            {
                // simulate door open
                ctx.Ui.OpenDoor();
                Assert.IsTrue(ctx.Hw.LightOn, "ensure the light is on after door closing");

                // simulate door close
                ctx.Ui.CloseDoor();
                Assert.IsFalse(ctx.Hw.LightOn, "ensure the light is off after door closing");
            }
        }
        public void US6_When_button_pressed_and_door_closed_and_heating_increase_time_1_minute(IMicrowaveOvenControler ctrl, IMicrowaveOvenHWEx hw)
        {
            using (var ctx = new MicrowaveTestSetup(ctrl, hw))
            {
                // simulate press start button
                ctx.Ui.PressStartButton();

                Assert.IsTrue(ctx.Hw.HeaterOn,
                              "ensure the heater has been started after 'PressStartButton'");

                SimulateTimeElapse(ctx.Ctrl, 59);

                // simulate second press of the start button
                ctx.Ui.PressStartButton();

                Assert.IsTrue(ctx.Hw.HeaterOn, "ensure the heater is still on");

                SimulateTimeElapse(ctx.Ctrl, 60);

                Assert.IsTrue(ctx.Hw.HeaterOn,
                              "ensure the heater is on 1 second before the end of heating (60 + 59 seconds)");

                SimulateTimeElapse(ctx.Ctrl, 1);

                Assert.IsFalse(ctx.Hw.HeaterOn,
                               "ensure the heater is off when 60 second elapsed");
            }
        }
        public void US4_When_I_press_start_button_when_door_is_open_nothing_happens(IMicrowaveOvenControler ctrl, IMicrowaveOvenHWEx hw)
        {
            using (var ctx = new MicrowaveTestSetup(ctrl, hw))
            {
                // simulate door open
                ctx.Ui.OpenDoor();

                Assert.IsTrue(ctx.Hw.DoorOpen, "ensure if door state is correct");
                Assert.IsTrue(ctx.Hw.LightOn, "ensure the light is on");
                Assert.IsFalse(ctx.Hw.HeaterOn, "ensure the heater is off");

                // simulate press start button
                ctx.Ui.PressStartButton();

                Assert.IsFalse(ctx.Hw.HeaterOn, "ensure if heating has not been started after 'PressStartButton'");
            }
        }