public void ExecutionPlan_HasExpectedAscUpToMaxFloorThenDesc_WhenSummonedFrom3FloorsTo2DifferentsFloors()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(2, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon1  = new SummonInformation(0, TravelDirection.Up);
            SummonInformation         request1 = new SummonInformation(5, TravelDirection.None, summon1);
            SummonInformation         summon2  = new SummonInformation(4, TravelDirection.Down);
            SummonInformation         summon3  = new SummonInformation(10, TravelDirection.Down);
            SummonInformation         request2 = new SummonInformation(0, TravelDirection.None, summon2);
            SummonInformation         request3 = new SummonInformation(0, TravelDirection.None, summon3);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon1,
                request1,
                summon2,
                summon3,
                request2,
                request3
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(summon1.SummonFloor, planResult.ElementAt(0));
            Assert.Equal(request1.SummonFloor, planResult.ElementAt(1));
            Assert.Equal(summon3.SummonFloor, planResult.ElementAt(2));
            Assert.Equal(summon2.SummonFloor, planResult.ElementAt(3));
            Assert.Equal(request2.SummonFloor, planResult.ElementAt(4));
        }
        public void Lift_CreateExecutionPlanWith6Values_WhenSummonedFrom3FloorsTo3DifferentsFloors()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(0, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon1  = new SummonInformation(0, TravelDirection.Up);
            SummonInformation         request1 = new SummonInformation(5, TravelDirection.None, summon1);
            SummonInformation         summon2  = new SummonInformation(4, TravelDirection.Down);
            SummonInformation         summon3  = new SummonInformation(10, TravelDirection.Down);
            SummonInformation         request2 = new SummonInformation(1, TravelDirection.None, summon2);
            SummonInformation         request3 = new SummonInformation(8, TravelDirection.None, summon3);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon1,
                request1,
                summon2,
                summon3,
                request2,
                request3
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(6, planResult.Count());
        }
        public void ExecutionPlan_HasSummonAndDesitnationDescOrder_WhenSummonedFrom2FloorsToGoDownAndParkedHigherThanBothAndRequestImmediatlyFollowSummonAndFirstRequestIsFromLowerFloor()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(8, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon1  = new SummonInformation(6, TravelDirection.Down);
            SummonInformation         request1 = new SummonInformation(1, TravelDirection.None, summon1);
            SummonInformation         summon2  = new SummonInformation(4, TravelDirection.Down);
            SummonInformation         request2 = new SummonInformation(1, TravelDirection.None, summon2);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon2,
                request2,
                summon1,
                request1
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(summon1.SummonFloor, planResult.ElementAt(0));
            Assert.Equal(summon2.SummonFloor, planResult.ElementAt(1));
            Assert.Equal(request1.SummonFloor, planResult.ElementAt(2));
        }
        public void ExecutionPlan_HasSummonAndDesitnationAscOrder_WhenSummonedFrom2DifferentFloorsAndFirstSummonRequestUpAndSecondSummonRequestDown()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(6, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon1  = new SummonInformation(6, TravelDirection.Up);
            SummonInformation         request1 = new SummonInformation(13, TravelDirection.None, summon1);
            SummonInformation         summon2  = new SummonInformation(5, TravelDirection.Down);
            SummonInformation         request2 = new SummonInformation(1, TravelDirection.None, summon2);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon1,
                request1,
                summon2,
                request2
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(summon1.SummonFloor, planResult.ElementAt(0));
            Assert.Equal(request1.SummonFloor, planResult.ElementAt(1));
            Assert.Equal(summon2.SummonFloor, planResult.ElementAt(2));
            Assert.Equal(request2.SummonFloor, planResult.ElementAt(3));
        }
        public void ExecutionPlan_HasSummonAndDesitnationAscOrder_WhenSummonedFrom2DifferentFloorsHigherThanParkedToUpAndDifferentRequestedFloorsAndUser2RequestLowerFloorThanUser1SummoningAndParkedFloorInBetween()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(5, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon1  = new SummonInformation(6, TravelDirection.Up);
            SummonInformation         request1 = new SummonInformation(9, TravelDirection.None, summon1);
            SummonInformation         summon2  = new SummonInformation(0, TravelDirection.Up);
            SummonInformation         request2 = new SummonInformation(3, TravelDirection.None, summon2);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon1,
                request1,
                summon2,
                request2
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(summon1.SummonFloor, planResult.ElementAt(0));
            Assert.Equal(request1.SummonFloor, planResult.ElementAt(1));
            Assert.Equal(summon2.SummonFloor, planResult.ElementAt(2));
            Assert.Equal(request2.SummonFloor, planResult.ElementAt(3));
        }
Exemple #6
0
        public void Lift_CreateExecutionPlanWith2Values_WhenParkedOnLowerFloorAndSummonToGoUp()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(0, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon   = new SummonInformation(1, TravelDirection.Up);
            SummonInformation         request  = new SummonInformation(5, TravelDirection.None, summon);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon,
                request
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(2, planResult.Count());
        }
Exemple #7
0
        public void ExecutionPlan_HasSummonAndDesitnationInOrder_WhenParkedOnLowerFloorAndSummonToGoUp()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(0, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon   = new SummonInformation(1, TravelDirection.Up);
            SummonInformation         request  = new SummonInformation(5, TravelDirection.None, summon);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon,
                request
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(summon.SummonFloor, planResult.First());
            Assert.Equal(request.SummonFloor, planResult.Last());
        }
Exemple #8
0
        public void Lift_CreateExecutionPlanWith2Values_WhenParkedAndSummonedOnCurrentFloorForLowerFloor()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(3, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon   = new SummonInformation(3, TravelDirection.Down);
            SummonInformation         request  = new SummonInformation(1, TravelDirection.None, summon);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon,
                request
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(2, planResult.Count());
            Assert.Equal(summon.SummonFloor, planResult.First());
            Assert.Equal(request.SummonFloor, planResult.Last());
        }
        public void Lift_CreateExecutionPlanWith3Values_WhenSummonedFrom2FloorsHigherThanParkedToGoDownAndDifferentRequestedFloors()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(5, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon1  = new SummonInformation(6, TravelDirection.Down);
            SummonInformation         request1 = new SummonInformation(1, TravelDirection.None, summon1);
            SummonInformation         summon2  = new SummonInformation(9, TravelDirection.Down);
            SummonInformation         request2 = new SummonInformation(3, TravelDirection.None, summon2);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon1,
                request1,
                summon2,
                request2
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(4, planResult.Count());
        }