Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deprecated - helper function for simple allocation test
        /// </summary>
        /// <returns></returns>
        public static TestDriverSet GetTestDrivers()
        {
            TestDriverSet testDriverSet = new TestDriverSet();

            testDriverSet.testDrivers = new List <Driver>();

            Driver d = new Driver();

            d.name    = "James";
            d.address = new Address();
            d.address.addressString = "Wonder Drive";
            d.address.x             = 55;
            d.address.y             = 20;
            d.reviewRating          = 4;
            d.todaysOrders          = 4;
            testDriverSet.testDrivers.Add(d);

            d         = new Driver();
            d.name    = "Bruce";
            d.address = new Address();
            d.address.addressString = "Mountain Drive";
            d.address.x             = 42;
            d.address.y             = 20;
            d.reviewRating          = 4;
            d.todaysOrders          = 2;
            testDriverSet.testDrivers.Add(d);


            d         = new Driver();
            d.name    = "Ethan";
            d.address = new Address();
            d.address.addressString = "Central square";
            d.address.x             = 45;
            d.address.y             = 20;
            d.reviewRating          = 4;
            d.todaysOrders          = 2;
            testDriverSet.testDrivers.Add(d);

            testDriverSet.expectedSelection = testDriverSet.testDrivers[2];

            return(testDriverSet);
        }