Exemplo n.º 1
0
            public void WhenOpenDoorsAndNoDirection_ThenLiftDoorsOpenAndSetDireciton()
            {
                var lift = new Lift()
                {
                    Level     = 5,
                    State     = LiftState.Stopped,
                    Direction = null
                };

                var passengerGettingOn = new Passenger(0);
                var summons            = new List <Summon>()
                {
                    new Summon(5, Direction.Down, new List <Passenger>()
                    {
                        passengerGettingOn
                    })
                };

                LiftService.ExecuteInstruction(Instruction.OpenDoors, lift, summons);

                Assert.True(lift.State == LiftState.DoorsOpen);
                // passengers get on
                Assert.Contains(passengerGettingOn, lift.Passengers);
                // answered summons are removed
                Assert.Empty(summons);
                // direction set
                Assert.True(lift.Direction == Direction.Down);
            }
Exemplo n.º 2
0
            public void WhenStop_ThenLiftStopped()
            {
                var lift = new Lift()
                {
                    State = LiftState.Moving
                };
                var summons = new List <Summon>();

                LiftService.ExecuteInstruction(Instruction.Stop, lift, summons);

                Assert.True(lift.State == LiftState.Stopped);
            }
Exemplo n.º 3
0
            public void WhenTravelDown_ThenMoveLiftDown()
            {
                var lift = new Lift()
                {
                    Level = 5,
                    State = LiftState.Stopped
                };
                var summons = new List <Summon>();

                LiftService.ExecuteInstruction(Instruction.TravelDown, lift, summons);

                Assert.True(lift.State == LiftState.Moving);
                Assert.True(lift.Direction == Direction.Down);
                Assert.True(lift.Level == 4);
            }