Exemple #1
0
 //convenience contructor to help generate the test case
 public DriverComparisonTestPair(string d1Name, int d1Orders, int d1Rating, int d1Distance, int d1Duration,
                                 string d2Name, int d2Orders, int d2Rating, int d2Distance, int d2Duration, string expectedSelectionName)
 {
     driver1 = new AllocationEngine.CandidateDriver()
     {
         driverInfo = new Driver()
         {
             name         = d1Name,
             todaysOrders = d1Orders,
             reviewRating = d1Rating,
         },
         tripDetails = new AllocationEngine.TripDetails()
         {
             distance        = d1Distance,
             durationMinutes = d1Duration
         }
     };
     driver2 = new AllocationEngine.CandidateDriver()
     {
         driverInfo = new Driver()
         {
             name         = d2Name,
             todaysOrders = d2Orders,
             reviewRating = d2Rating,
         },
         tripDetails = new AllocationEngine.TripDetails()
         {
             distance        = d2Distance,
             durationMinutes = d2Duration
         }
     };
     expectedSelectionDrivername = expectedSelectionName;
 }
Exemple #2
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);
        }