Ejemplo n.º 1
0
        public void elever_should_still_have_power_after_going_up_and_down_five_times_if_maintainlevel_is_six()
        {
            var elevator = new Elevator("", lowestFloor: -2, highestFloor: 3, startFloor: 1, untilMaintainance: 6);

            elevator.TryGoDown();
            elevator.TryGoUp();

            elevator.TryGoDown();
            elevator.TryGoUp();

            elevator.TryGoDown();

            Assert.IsTrue(elevator.PowerIsOn);
        }
Ejemplo n.º 2
0
        public void elevator_should_report_that_it_cant_move_when_go_down_signal_on_lowest_floor()
        {
            var elevator = new Elevator("", lowestFloor: 0, highestFloor: 5, startFloor: 0, untilMaintainance: 1000);
            var response = elevator.TryGoDown();

            Assert.AreEqual(ElevatorMoveResponse.CantMoveDown, response);
            Assert.AreEqual(1000, elevator.UntilMaintainance);
        }
Ejemplo n.º 3
0
        public void elevator_should_be_at_level_0_when_it_starts_at_1_and_go_down_one_floor()
        {
            var elevator = new Elevator("", lowestFloor: -2, highestFloor: 3, startFloor: 1, untilMaintainance: 6);

            var response = elevator.TryGoDown();

            Assert.AreEqual(0, elevator.CurrentFloor);
            Assert.AreEqual(ElevatorMoveResponse.MoveSuccess, response);
        }
Ejemplo n.º 4
0
        public void elevator_should_be_at_level_negative_1_when_it_starts_at_5_and_go_down_6_floors()
        {
            // ARRANGE
            var x = new Elevator("e1", 5, -2, 10, 3);

            // ACT
            x.TryGoDown(6);
            // ASSERT
            Assert.AreEqual(-1, x.CurrentFloor);
        }
Ejemplo n.º 5
0
        public void elevator_should_not_move_when_power_is_off()
        {
            // ARRANGE
            var x = new Elevator("e1", 0, -2, 10, 0);
            // ACT
            ElevatorMoveResponse result   = x.TryGoDown();
            ElevatorMoveResponse expected = ElevatorMoveResponse.NoPower;

            // ASSERT
            Assert.AreEqual(expected, result);
            Assert.AreEqual(0, x.CurrentFloor);
        }
Ejemplo n.º 6
0
        public void elevator_should_not_go_down_when_it_starts_at_negative_2_and_go_down_one_floor()
        {
            // ARRANGE
            var x = new Elevator("e1", -2, -2, 10, 3);
            // ACT
            ElevatorMoveResponse result   = x.TryGoDown();
            ElevatorMoveResponse expected = ElevatorMoveResponse.CantGoDown;

            // ASSERT
            Assert.AreEqual(expected, result);
            Assert.AreEqual(-2, x.CurrentFloor);
        }
Ejemplo n.º 7
0
        public void elevator_should_be_at_bottom_floor_when_go_down_is_called_really_many_times()
        {
            var elevator = new Elevator("", lowestFloor: -2, highestFloor: 3, startFloor: 1, untilMaintainance: 6);


            for (int i = 0; i < 100; i++)
            {
                elevator.TryGoDown();
            }

            Assert.AreEqual(-2, elevator.CurrentFloor);
        }