Ejemplo n.º 1
0
 public void GivenUserId_InvoiceServiceGetsListOfRidesFromRideRepository_ReturnInvoice()
 {
     try
     {
         //add user rides using user ID
         string userId = "*****@*****.**";
         //add number of rides
         Ride[] ride =
         {
             new Ride("normal", 20, 15),
             new Ride("normal", 10, 25),
             new Ride("normal", 12, 40)
         };
         RideRepository rideRepository = new RideRepository();
         //add userID and rides
         rideRepository.AddRides(userId, ride);
         Invoicegenerator carride = new Invoicegenerator();
         //calculate total cab fare for all rides
         double ridetotalFare = carride.CalculateMonthlyFare(rideRepository.GetRides(userId));
         Assert.AreEqual(500, ridetotalFare);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Ejemplo n.º 2
0
 public void GivenDistanceAndTime_whenTakeMultipleRides_ReturnEnhancedInVoice()
 {
     try
     {
         Invoicegenerator carride = new Invoicegenerator();
         //add number of rides
         Ride[] ride =
         {
             new Ride("normal", 10, 12),
             new Ride("normal", 10, 14),
             new Ride("normal", 20, 18)
         };
         //calculate total fare
         double totalfare = carride.CalculateMonthlyFare(ride);
         //calculate number of rides
         int totalRides = carride.numberofRides;
         //calculate average fare for rides
         double averageFare = Math.Round(carride.Aggregate, 2);
         Assert.AreEqual(444, totalfare);
         Assert.AreEqual(3, totalRides);
         Assert.AreEqual(148.0, averageFare);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Ejemplo n.º 3
0
 public void GivenUserId_whenNormalandPremiumJoourney_ReturnTotalFare()
 {
     try
     {
         //add user rides using user ID
         string userId = "*****@*****.**";
         //add number of rides
         Ride[] ride =
         {
             new Ride("premium", 50, 15),
             new Ride("normal",  30, 25),
             new Ride("premium", 60, 40),
             new Ride("normal",  12, 40)
         };
         RideRepository rideRepository = new RideRepository();
         //add userID and rides
         rideRepository.AddRides(userId, ride);
         Invoicegenerator carride = new Invoicegenerator();
         //calculate total cab fare for all rides
         double ridetotalFare = carride.CalculateMonthlyFare(rideRepository.GetRides(userId));
         Assert.AreEqual(2245, ridetotalFare);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
        public void givenDistanceAndTime_ShouldReturnFare()
        {
            Invoicegenerator invoiceGenerator = new Invoicegenerator();
            double           distance         = 2.0;
            int    time = 5;
            double fare = invoiceGenerator.CalculateFare(distance, time);

            Assert.AreEqual(25, fare);
        }
        public void givenless_DistanceAndTime_ShouldReturnMinimumFare()
        {
            Invoicegenerator invoiceGenerator = new Invoicegenerator();
            double           distance         = 0.1;
            int    time = 1;
            double fare = invoiceGenerator.CalculateFare(distance, time);

            Assert.AreEqual(5, fare);
        }
        public void givenMultipleRide_shouldReturnInvoiceSummary()
        {
            List <Ride> rides = new List <Ride> {
                new Ride(2.0, 5), new Ride(2.0, 5)
            };
            InvoiceSummary   Expectedsummary  = new InvoiceSummary(2, 50, 25);
            Invoicegenerator invoiceGenerator = new Invoicegenerator();
            InvoiceSummary   summary          = invoiceGenerator.CalculateFare(rides, RideType.NORMAL_RIDE);

            Assert.AreEqual(Expectedsummary, summary);
        }