Esempio n. 1
0
        public void test04ElevatorControllerCanHaveMoreThanOneView()
        {
            ElevatorController           elevatorController           = new ElevatorController();
            ElevatorControllerConsole    elevatorControllerConsole    = new ElevatorControllerConsole(elevatorController);
            ElevatorControllerStatusView elevatorControllerStatusView = new ElevatorControllerStatusView(elevatorController);

            elevatorController.goUpPushedFromFloor(1);
            elevatorController.cabinDoorClosed();
            elevatorController.cabinOnFloor(1);

            IEnumerator <String> reader = elevatorControllerConsole.consoleReader();

            reader.MoveNext();
            Assert.AreEqual("Puerta Cerrandose", reader.Current);
            reader.MoveNext();
            Assert.AreEqual("Puerta Cerrada", reader.Current);
            reader.MoveNext();
            Assert.AreEqual("Cabina Moviendose", reader.Current);
            reader.MoveNext();
            Assert.AreEqual("Cabina Detenida", reader.Current);
            reader.MoveNext();
            Assert.AreEqual("Puerta Abriendose", reader.Current);
            Assert.IsFalse(reader.MoveNext());

            Assert.AreEqual("Stopped", elevatorControllerStatusView.cabinFieldModel());
            Assert.AreEqual("Opening", elevatorControllerStatusView.cabinDoorFieldModel());
        }
Esempio n. 2
0
        public void testElevatorCompletesAllTheRequests()
        {
            ElevatorController elevatorController = new ElevatorController();

            elevatorController.goUpPushedFromFloor(1);
            elevatorController.cabinDoorClosed();
            elevatorController.goUpPushedFromFloor(2);
            elevatorController.cabinOnFloor(1);
            elevatorController.cabinDoorOpened();
            elevatorController.waitForPeopleTimedOut();
            elevatorController.cabinDoorClosed();
            elevatorController.cabinOnFloor(2);

            Assert.IsTrue(elevatorController.isWorking());
            Assert.IsTrue(elevatorController.isCabinStopped());
            Assert.IsTrue(elevatorController.isCabinDoorOpening());
        }
Esempio n. 3
0
        public void testElevatorHasToEnterEmergencyIfFalling()
        {
            ElevatorController elevatorController = new ElevatorController();

            elevatorController.goUpPushedFromFloor(2);
            elevatorController.cabinDoorClosed();
            elevatorController.cabinOnFloor(1);
            try
            {
                elevatorController.cabinOnFloor(0);
                Assert.Fail();
            }
            catch (Exception elevatorEmergency)
            {
                Assert.IsTrue(elevatorEmergency.Message == "Sensor de cabina desincronizado");
            }
        }
Esempio n. 4
0
        public void testCabinHasToStopOnFloorsOnItsWayNoMatterHowTheyWellCalled()
        {
            ElevatorController elevatorController = new ElevatorController();

            elevatorController.goUpPushedFromFloor(2);
            elevatorController.cabinDoorClosed();
            elevatorController.goUpPushedFromFloor(1);
            elevatorController.cabinOnFloor(1);

            Assert.IsTrue(elevatorController.isWorking());
            Assert.IsTrue(elevatorController.isCabinStopped());
            Assert.IsTrue(elevatorController.isCabinDoorOpening());
        }
Esempio n. 5
0
        public void testRequestToGoUpAreEnqueueWhenRequestedWhenCabinIsMoving()
        {
            ElevatorController elevatorController = new ElevatorController();

            elevatorController.goUpPushedFromFloor(1);
            elevatorController.cabinDoorClosed();
            elevatorController.cabinOnFloor(1);
            elevatorController.goUpPushedFromFloor(2);
            elevatorController.cabinDoorOpened();

            Assert.IsTrue(elevatorController.isWorking());
            Assert.IsTrue(elevatorController.isCabinWaitingForPeople());
            Assert.IsTrue(elevatorController.isCabinDoorOpened());
        }
Esempio n. 6
0
        public void testCabinDoorStartClosingAfterWaitingForPeople()
        {
            ElevatorController elevatorController = new ElevatorController();

            elevatorController.goUpPushedFromFloor(1);
            elevatorController.cabinDoorClosed();
            elevatorController.cabinOnFloor(1);
            elevatorController.goUpPushedFromFloor(2);
            elevatorController.cabinDoorOpened();
            elevatorController.waitForPeopleTimedOut();

            Assert.IsTrue(elevatorController.isWorking());
            Assert.IsTrue(elevatorController.isCabinStopped());
            Assert.IsTrue(elevatorController.isCabinDoorClosing());
        }
Esempio n. 7
0
        public void testDoorKeepsOpeneingWhenItIsOpeneing()
        {
            ElevatorController elevatorController = new ElevatorController();

            elevatorController.goUpPushedFromFloor(1);
            elevatorController.cabinDoorClosed();
            elevatorController.cabinOnFloor(1);

            Assert.IsTrue(elevatorController.isWorking());
            Assert.IsTrue(elevatorController.isCabinStopped());
            Assert.IsTrue(elevatorController.isCabinDoorOpening());

            elevatorController.openCabinDoor();
            Assert.IsTrue(elevatorController.isWorking());
            Assert.IsTrue(elevatorController.isCabinStopped());
            Assert.IsTrue(elevatorController.isCabinDoorOpening());
        }
Esempio n. 8
0
        public void testCloseDoorDoesNothingWhenOpeningTheDoorToWaitForPeople()
        {
            ElevatorController elevatorController = new ElevatorController();

            elevatorController.goUpPushedFromFloor(1);
            elevatorController.cabinDoorClosed();
            elevatorController.cabinOnFloor(1);

            Assert.IsTrue(elevatorController.isWorking());
            Assert.IsTrue(elevatorController.isCabinStopped());
            Assert.IsTrue(elevatorController.isCabinDoorOpening());

            elevatorController.closeCabinDoor();

            Assert.IsTrue(elevatorController.isWorking());
            Assert.IsTrue(elevatorController.isCabinStopped());
            Assert.IsTrue(elevatorController.isCabinDoorOpening());
        }
Esempio n. 9
0
        public void testStopsWaitingForPeopleIfCloseDoorIsPressed()
        {
            ElevatorController elevatorController = new ElevatorController();

            elevatorController.goUpPushedFromFloor(1);
            elevatorController.cabinDoorClosed();
            elevatorController.cabinOnFloor(1);
            elevatorController.goUpPushedFromFloor(2);
            elevatorController.cabinDoorOpened();

            Assert.IsTrue(elevatorController.isWorking());
            Assert.IsTrue(elevatorController.isCabinWaitingForPeople());
            Assert.IsTrue(elevatorController.isCabinDoorOpened());

            elevatorController.closeCabinDoor();

            Assert.IsTrue(elevatorController.isWorking());
            Assert.IsTrue(elevatorController.isCabinStopped());
            Assert.IsTrue(elevatorController.isCabinDoorClosing());
        }
Esempio n. 10
0
        public void testCabinStopsAndStartsOpeningDoorWhenGetsToDestination()
        {
            ElevatorController elevatorController = new ElevatorController();

            elevatorController.goUpPushedFromFloor(1);
            elevatorController.cabinDoorClosed();
            elevatorController.cabinOnFloor(1);

            Assert.IsFalse(elevatorController.isIdle());
            Assert.IsTrue(elevatorController.isWorking());

            Assert.IsTrue(elevatorController.isCabinStopped());
            Assert.IsFalse(elevatorController.isCabinMoving());

            Assert.IsFalse(elevatorController.isCabinDoorOpened());
            Assert.IsTrue(elevatorController.isCabinDoorOpening());
            Assert.IsFalse(elevatorController.isCabinDoorClosing());
            Assert.IsFalse(elevatorController.isCabinDoorClosed());

            Assert.AreEqual(1, elevatorController.cabinFloorNumber());
        }
Esempio n. 11
0
        public void test03ElevatorControllerConsoleTracksCabinAndDoorStateChanges()
        {
            ElevatorController        elevatorController        = new ElevatorController();
            ElevatorControllerConsole elevatorControllerConsole = new ElevatorControllerConsole(elevatorController);

            elevatorController.goUpPushedFromFloor(1);
            elevatorController.cabinDoorClosed();
            elevatorController.cabinOnFloor(1);

            IEnumerator <String> reader = elevatorControllerConsole.consoleReader();

            reader.MoveNext();
            Assert.AreEqual("Puerta Cerrandose", reader.Current);
            reader.MoveNext();
            Assert.AreEqual("Puerta Cerrada", reader.Current);
            reader.MoveNext();
            Assert.AreEqual("Cabina Moviendose", reader.Current);
            reader.MoveNext();
            Assert.AreEqual("Cabina Detenida", reader.Current);
            reader.MoveNext();
            Assert.AreEqual("Puerta Abriendose", reader.Current);
            Assert.IsFalse(reader.MoveNext());
        }