예제 #1
0
 public void SetDepartureTime(TravelTime timeOfDeparture)
 {
     if (timeOfDeparture != null)
     {
         _departureTime = timeOfDeparture;
     }
 }
        public void TestCalculateTravelTime()
        {
            Vehicle    myVehicle   = new Vehicle(35);
            TravelTime packageTime = new TravelTime(16, 45, 56);

            _testDelivery = new Delivery(packageTime, myVehicle);

            double travelTime = _testDelivery.CalculateTravelTime(60);

            Assert.AreEqual(18.48, travelTime);
        }
        public void TestCreateUniqueIds()
        {
            Vehicle    myVehicle1   = new Vehicle(25);
            TravelTime packageTime1 = new TravelTime(4, 30, 25);
            Delivery   firstPackage = new Delivery(packageTime1, myVehicle1);

            Vehicle    myVehicle2    = new Vehicle(50);
            TravelTime packageTime2  = new TravelTime(6, 0, 4);
            Delivery   secondpackage = new Delivery(packageTime2, myVehicle2);

            Assert.AreNotEqual(firstPackage.UniqueTrackingNumber, secondpackage.UniqueTrackingNumber);
        }
        public void TestSetDepartureTime()
        {
            int seconds = 15;
            int minutes = 15;
            int hours   = 5;

            TravelTime departTime = new TravelTime(hours, minutes, seconds);

            _testDelivery.SetDepartureTime(departTime);

            Assert.AreEqual(_testDelivery.DepartureTime, departTime);
        }
예제 #5
0
        public static List <Delivery> CreateDelivery(int numberOfDelivery, List <Vehicle> vehicleList)
        {
            List <Delivery> packageList = new List <Delivery>();

            for (int count = 0; count < numberOfDelivery; count++)
            {
                int vehicleIndex = count % vehicleList.Count == 0 ? 0 : 1;

                TravelTime newDepartTime = new TravelTime(count + 10 + vehicleIndex,
                                                          count + 10 + vehicleIndex * 2, count + 10 + vehicleIndex * 3);

                Delivery newDelivery = new Delivery(newDepartTime, vehicleList[vehicleIndex]);
                packageList.Add(newDelivery);
            }

            return(packageList);
        }
예제 #6
0
 public Delivery(TravelTime departureTime, Vehicle vehicle)
 {
     _departureTime = departureTime;
     CreateUniqueTrackingNumber();
     _deliveryVehicle = vehicle;
 }
예제 #7
0
 public Delivery()
 {
     _departureTime        = new TravelTime(0, 0, 0);
     _uniqueTrackingNumber = string.Empty;
     _deliveryVehicle      = new Vehicle(25);
 }