示例#1
0
            public void WhenDoorsOpenAndSummonsAtSameLevelAndDirection_ThenStayOpen()
            {
                var lift = new Lift
                {
                    Level     = 1,
                    State     = LiftState.DoorsOpen,
                    Direction = Direction.Up
                };
                var summons = new List <Summon>()
                {
                    new Summon(1, Direction.Up, new List <Passenger>())
                };
                var nextInstruction = LiftService.CalculateNextInstruction(lift, summons);

                Assert.True(nextInstruction == Instruction.OpenDoors);
            }
示例#2
0
            public void WhenStoppedDirectionDownAndSummonsBelow_ThenTravelDown()
            {
                var lift = new Lift
                {
                    Level     = 5,
                    State     = LiftState.Stopped,
                    Direction = Direction.Down
                };
                var summons = new List <Summon>()
                {
                    new Summon(2, Direction.Up, new List <Passenger>())
                };
                var nextInstruction = LiftService.CalculateNextInstruction(lift, summons);

                Assert.True(nextInstruction == Instruction.TravelDown);
            }
示例#3
0
            public void WhenDoorsOpenAndPassengerAtDesiredLevel_ThenStayOpen()
            {
                var lift = new Lift
                {
                    Level      = 1,
                    State      = LiftState.DoorsOpen,
                    Passengers = new List <Passenger>()
                    {
                        new Passenger(1)
                    }
                };
                var summons         = new List <Summon>();
                var nextInstruction = LiftService.CalculateNextInstruction(lift, summons);

                Assert.True(nextInstruction == Instruction.OpenDoors);
            }
示例#4
0
            public void WhenStoppedDirectionUpAndSummonsAbove_ThenTravelUp()
            {
                var lift = new Lift
                {
                    Level     = 1,
                    State     = LiftState.Stopped,
                    Direction = Direction.Up
                };
                var summons = new List <Summon>()
                {
                    new Summon(2, Direction.Down, new List <Passenger>())
                };
                var nextInstruction = LiftService.CalculateNextInstruction(lift, summons);

                Assert.True(nextInstruction == Instruction.TravelUp);
            }
示例#5
0
            public void WhenStoppedAndDirectionDownAndNoPassengersAndNoSummonsBelowAndSummonOnLevel_ThenOpenDoors()
            {
                var lift = new Lift
                {
                    Level     = 5,
                    State     = LiftState.Stopped,
                    Direction = Direction.Down
                };
                var summons = new List <Summon>()
                {
                    new Summon(5, Direction.Up, new List <Passenger>())
                };
                var nextInstruction = LiftService.CalculateNextInstruction(lift, summons);

                Assert.True(nextInstruction == Instruction.OpenDoors);
            }
示例#6
0
            public void WhenStoppedAndSummonsAtSameLevelWithOppositeDirectionAndSummonsInSameDirection_ThenDontOpen()
            {
                var lift = new Lift
                {
                    Level     = 1,
                    State     = LiftState.Stopped,
                    Direction = Direction.Up
                };
                var summons = new List <Summon>()
                {
                    new Summon(1, Direction.Down, new List <Passenger>()), new Summon(2, Direction.Down, new List <Passenger>())
                };
                var nextInstruction = LiftService.CalculateNextInstruction(lift, summons);

                Assert.False(nextInstruction == Instruction.OpenDoors);
            }
示例#7
0
            public void WhenMovingAndSummonAtLevelWithOppositeDirectionAndNoOtherSummonsOrPassengers_ThenStop()
            {
                var lift = new Lift
                {
                    Level      = 5,
                    State      = LiftState.Moving,
                    Direction  = Direction.Down,
                    Passengers = new List <Passenger>()
                };
                var summons = new List <Summon>()
                {
                    new Summon(5, Direction.Up, new List <Passenger>())
                };
                var nextInstruction = LiftService.CalculateNextInstruction(lift, summons);

                Assert.True(nextInstruction == Instruction.Stop);
            }
示例#8
0
            public void WhenMovingAndPassengerAtDesiredLevel_ThenStop()
            {
                var lift = new Lift
                {
                    Level      = 1,
                    State      = LiftState.Moving,
                    Direction  = Direction.Up,
                    Passengers = new List <Passenger>()
                    {
                        new Passenger(1)
                    }
                };
                var summons         = new List <Summon>();
                var nextInstruction = LiftService.CalculateNextInstruction(lift, summons);

                Assert.True(nextInstruction == Instruction.Stop);
            }
示例#9
0
            public void WhenStoppedAndDirectionDownAndPassengersDesiredLevelBelow_ThenTravelDown()
            {
                var lift = new Lift
                {
                    Level      = 5,
                    State      = LiftState.Stopped,
                    Direction  = Direction.Down,
                    Passengers = new List <Passenger>()
                    {
                        new Passenger(2)
                    }
                };
                var summons         = new List <Summon>();
                var nextInstruction = LiftService.CalculateNextInstruction(lift, summons);

                Assert.True(nextInstruction == Instruction.TravelDown);
            }
示例#10
0
            public void WhenStoppedDirectionUpAndPassengersDesiredLevelAbove_ThenTravelUp()
            {
                var lift = new Lift
                {
                    Level      = 1,
                    State      = LiftState.Stopped,
                    Direction  = Direction.Up,
                    Passengers = new List <Passenger>()
                    {
                        new Passenger(4)
                    }
                };
                var summons         = new List <Summon>();
                var nextInstruction = LiftService.CalculateNextInstruction(lift, summons);

                Assert.True(nextInstruction == Instruction.TravelUp);
            }