Exemple #1
0
        /// <summary>
        /// test function to test the simple allocation from Day-1
        /// </summary>
        public static void TestSimpleAllocation()
        {
            Order testorder = GetTestOrder();

            Console.WriteLine("Allocating drivers to Order" + testorder.DummyOrderDetails);

            TestDriverSet testDriverSet = GetTestDrivers();

            //List<Driver> selectedDrivers  = AllocationEngine.AllocateDrivers(testorder, testDrivers);
            List <Driver> selectedDrivers = AllocationEngine.DoAllocation(testorder.restaurant.address, testorder.consumer.address, testDriverSet.testDrivers);

            //for now we expect only one driver in the list
            if (selectedDrivers != null && selectedDrivers.Count > 0)
            {
                Console.WriteLine("Selected Driver is " + selectedDrivers[0].name);

                if (selectedDrivers[0].name == testDriverSet.expectedSelection.name)
                {
                    Console.WriteLine("Right selection");
                }
                else
                {
                    Console.WriteLine("Wrong selection");
                }
            }
            else
            {
                Console.WriteLine("No driver selected??!!");
            }

            //Assert.IsTrue(selectedDrivers[0].name == testDriverSet.expectedSelection.name);
        }
Exemple #2
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");
        }
Exemple #3
0
        public static void TestDriverComparison()
        {
            List <DriverComparisonTestPair> testCases = AllocationTestCaseService.GetDriverComparisonTestPairs();
            List <int> failedTestCases = new List <int>();
            int        i = 0;

            Console.WriteLine("\n*********\nSTART OF testing driver pair comparisons");
            foreach (DriverComparisonTestPair testCase in testCases)
            {
                AllocationEngine.CandidateDriver selection = AllocationEngine.GetDeservingCandidateDriver(testCase.driver1, testCase.driver2);
                Console.WriteLine("Compared " + testCase.driver1.driverInfo.name + " and " + testCase.driver2.driverInfo.name + " and selected " + selection.driverInfo.name);
                if (selection.driverInfo.name != testCase.expectedSelectionDrivername)
                {
                    failedTestCases.Add(i);
                    Console.WriteLine("Wrong selection");
                }
                else
                {
                    Console.WriteLine("Right selection");
                }
                i++;
            }

            if (failedTestCases.Count > 0)
            {
                Console.Write("TestDriverComparison failed tests : ");
                foreach (int n in failedTestCases)
                {
                    Console.Write("driver pair " + n + ";");
                }
            }
            else
            {
                Console.WriteLine("All driver compare tests passed!!");
            }

            Assert.IsTrue(failedTestCases.Count == 0);
        }