Пример #1
0
        public static DriverAllocationTestCase GetSingleorderDifferentRatingDriverTestCase()
        {
            DriverAllocationTestCase testCase = new DriverAllocationTestCase();

            //this list is hard coded here now, can be read from a test case file
            testCase.availableDrivers = new List <Driver>()
            {
                //name, addressstring,x,y,todaysOrders,reviewrating
                new Driver("James", "Wonder Drive", 35, 20, 0, 3)
                , new Driver("Bruce", "Mountain drive", 25, 20, 2, 4)
                , new Driver("Ethan", "Central square", 22, 20, 2, 4)
                , new Driver("Jason", "Farm Drive", 30, 20, 2, 5)
            };


            //the idea is to call allocation for orders one after the other
            //for now keeping it simple, not considering which driver is busy etc., assuming whoever is in the
            //above driver list are available at their home location and each order request comes one after the other
            //after the previous order is delivered and driver returned to base
            //so that each order in below list will be processed one after the other
            //assumed that whenever allocation is done todaysOrder count for each driver is incremented in the system

            //for testing the driver list with dynamic changes , another test case to be written

            //this list holds the order and the expected driver allocation for that when called one after the other
            //this list is hard coded here now, can be read from a test case file
            testCase.ordersWithExpectedAllocation = new List <Tuple <Order, string> >()
            {
                //new Order(orderDescString, prep time, consumerName, consumerAddr, consumerX, consumerY, restarantName, restaurantAddr, restaurantX, restaurantY), expectedSelection
                new Tuple <Order, string>(new Order("#1 Medium Pizza; INR 350", 10, "Forrest", "210, Lake Drive", 10, 10, "Pizza King", "220, Central Square", 20, 20), "Jason")
            };

            return(testCase);
        }
Пример #2
0
        public static void TestBetterAllocation(AllocationTestCaseService.AllocationTestCases fTestCaseId)
        {
            //get the test case data from a test case service
            DriverAllocationTestCase theTestCase = AllocationTestCaseService.GetDriverAllocationTestCase(fTestCaseId);

            RunAllocationtestCase(theTestCase, fTestCaseId);
        }
Пример #3
0
        public static void RunAllocationtestCase(DriverAllocationTestCase fTestCase, AllocationTestCaseService.AllocationTestCases fTestCaseId)
        {
            Console.WriteLine("\n********\nSTART OF Testing the allocation case  " + fTestCaseId.ToString());
            if (fTestCase == null)
            {
                Console.WriteLine("No test case found " + fTestCaseId.ToString());
                return;
            }
            //for each order in the test case, find the allocation and verify one after the other
            foreach (Tuple <Order, string> orderWithExpectedAllocation in fTestCase.ordersWithExpectedAllocation)
            {
                //Order testorder = GetTestOrder();

                //get the order in the test case for which allocation to be done and the expected driver to be allocated as per test case definition
                Order  testOrder          = (Order)orderWithExpectedAllocation.Item1;
                string expectedDriverName = (string)orderWithExpectedAllocation.Item2;

                Console.WriteLine("\nAllocating drivers to Order" + testOrder.DummyOrderDetails);

                //TestDriverSet testDriverSet = GetTestDrivers();

                //Perform the actual allocation
                List <Driver> selectedDrivers = AllocationEngine.DoBetterAllocation(testOrder.restaurant.address, testOrder.consumer.address, fTestCase.availableDrivers, testOrder.prepTimeMinutes);
                //for now we expect only one driver returned in the list
                if (selectedDrivers != null && selectedDrivers.Count > 0)
                {
                    Console.WriteLine("Selected Driver is " + selectedDrivers[0].name);

                    if (selectedDrivers[0].name == expectedDriverName)
                    {
                        Console.WriteLine("Right selection");
                        //increment the driver's orders so that in the next allocation call it is considered
                        selectedDrivers[0].todaysOrders++;
                    }
                    else
                    {
                        Console.WriteLine("Wrong selection");
                    }
                }
                else
                {
                    Console.WriteLine("No driver selected??!!");
                }

                Assert.IsTrue(selectedDrivers[0].name == expectedDriverName);
            }

            Console.WriteLine("\nEND OF Testing the allocation case  " + fTestCaseId.ToString() + "\n********\n");
        }
Пример #4
0
        public static List <DriverAllocationTestCase> GetSingleorderDifferentRatingDriverTestCaseList()
        {
            List <DriverAllocationTestCase> testCaseList = new List <DriverAllocationTestCase>();

            //Test case with higher rating driver gets allocated due delta being within buffer
            //though lower rating driver has less orders
            DriverAllocationTestCase testCase = new DriverAllocationTestCase();

            //this list is hard coded here now, can be read from a test case file
            testCase.availableDrivers = new List <Driver>()
            {
                //name, addressstring,x,y,todaysOrders,reviewrating
                new Driver("James", "Wonder Drive", 35, 20, 0, 3)
                , new Driver("Bruce", "Mountain drive", 25, 20, 2, 4)
                , new Driver("Ethan", "Central square", 22, 20, 2, 4)
                , new Driver("Jason", "Farm Drive", 30, 20, 2, 5)
            };
            testCase.ordersWithExpectedAllocation = new List <Tuple <Order, string> >()
            {
                //new Order(orderDescString, prep time, consumerName, consumerAddr, consumerX, consumerY, restarantName, restaurantAddr, restaurantX, restaurantY), expectedSelection
                new Tuple <Order, string>(new Order("#1 Medium Pizza; INR 350", 10, "Forrest", "210, Lake Drive", 10, 10, "Pizza King", "220, Central Square", 20, 20), "Jason")
            };
            testCaseList.Add(testCase);

            //Test case with lower rating driver gets allocated due to less orders as all higher rating drivers are beyond their bufferthreshold
            testCase = new DriverAllocationTestCase();
            //this list is hard coded here now, can be read from a test case file
            testCase.availableDrivers = new List <Driver>()
            {
                //name, addressstring,x,y,todaysOrders,reviewrating
                new Driver("James", "Wonder Drive", 35, 20, 0, 3)
                , new Driver("Bruce", "Mountain drive", 25, 20, 2, 4)
                , new Driver("Ethan", "Central square", 22, 20, 2, 4)
                , new Driver("Jason", "Farm Drive", 30, 20, 3, 5)
            };
            testCase.ordersWithExpectedAllocation = new List <Tuple <Order, string> >()
            {
                //new Order(orderDescString, prep time, consumerName, consumerAddr, consumerX, consumerY, restarantName, restaurantAddr, restaurantX, restaurantY), expectedSelection
                new Tuple <Order, string>(new Order("#1 Medium Pizza; INR 350", 10, "Forrest", "210, Lake Drive", 10, 10, "Pizza King", "220, Central Square", 20, 20), "James")
            };
            testCaseList.Add(testCase);

            return(testCaseList);
        }