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 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); } }
public void GivenMultipleRides_WhenUserId_thenShouldReturn_InvoiceSummary() { invoiceGenerator = new InvoiceGenerator(RideType.NORMAL); Ride[] rides = { new Ride(2.0, 5), new Ride(0.1, 1) }; RideRepository rideRepository = new RideRepository(); string userId = "Sanju"; rideRepository.AddRides(userId, rides); rideRepository.AddRides("Priyanshu", new Ride[] { new Ride(3.0, 6), new Ride(4.0, 8) }); rideRepository.AddRides("Himanshu", new Ride[] { new Ride(3.0, 6), new Ride(4.0, 8) }); Ride[] rideData = rideRepository.GetRides(userId); InvoiceSummary invoiceSummary = invoiceGenerator.CalculateAvrageFare(rideData); InvoiceSummary expectedSummary = new InvoiceSummary(2, 30.0, 15); Assert.AreEqual(expectedSummary, invoiceSummary); }
public void GivenMultipleRides_ShouldReturnTotalFare() { InvoiceGenerator invoiceGenerator = new InvoiceGenerator(); string userId = "soumen"; Rides firstRide = new Rides(2.0, 5); Rides secondRide = new Rides(0.1, 1); List <Rides> rides = new List <Rides> { firstRide, secondRide }; RideRepository.AddRides(userId, rides); InvoiceSummary invoiceSummary = invoiceGenerator.GetInvoiceSummary(userId); double expected = 30; Assert.AreEqual(expected, invoiceSummary.TotalFare); }
public void GivenUserId_whenNormalandPremiumJourney_ReturnTotalFare() { string userId = "*****@*****.**"; Ride[] ride = { new Ride("premium", 2.0, 5), new Ride("normal", 0.1, 1), }; RideRepository rideRepository = new RideRepository(); rideRepository.AddRides(userId, ride); double totalFare = invoiceGenerator.CalculateFare(rideRepository.GetRides(userId)); Assert.AreEqual(135, totalFare, delta: 0.0); }
public void GivenUserId_InvoiceServiceGetsListOfRidesFromRideRepository_ReturnInvoice() { string userId = "*****@*****.**"; Ride[] ride = { new Ride("normal", 2.0, 5), new Ride("normal", 0.1, 1), }; RideRepository rideRepository = new RideRepository(); rideRepository.AddRides(userId, ride); double totalFare = invoiceGenerator.CalculateFare(rideRepository.GetRides(userId)); Assert.AreEqual(90, totalFare, 0.0); }
public void GivenDistanceAndTimeOfMultiRidesToUserId_ShouldTotalFare() { string userId = "pratiksha@123"; Ride[] rides = { new Ride("normal", 2.0, 5), new Ride("normal", 0.1, 1) }; RideRepository rideRepository = new RideRepository(); rideRepository.AddRides(userId, rides); InvoiceSummary retunTotal = this.invoice.CalculateFare(rideRepository.GetRides(userId)); Assert.AreEqual(30, retunTotal.TotalFare); }
public void GivenUserId_InvoiceServiceGetsListOfRidesFromRideRepository_ReturnInvoice() { string userId = "*****@*****.**"; Ride[] ride = { new Ride("normal", 5, 15), new Ride("normal", 10, 25), new Ride("normal", 15, 40) }; RideRepository rideRepository = new RideRepository(); rideRepository.AddRides(userId, ride); InvoiceService invoice = new InvoiceService(); double totalFare = invoice.CalculateMonthlyFare(rideRepository.GetRides(userId)); Assert.AreEqual(380, totalFare); }
public void NormalAndPremiumRides() { string userId = "*****@*****.**"; Ride[] ride = { new Ride("normal", 10, 20), new Ride("premium", 0.1, 1), new Ride("premium", 12, 25), new Ride("normal", 0.2, 2) }; RideRepository rideRepository = new RideRepository(); rideRepository.AddRides(userId, ride); InvoiceService invoiceService = new InvoiceService(); double totalFare = invoiceService.CalculateMonthlyFare(rideRepository.GetRides(userId)); Assert.AreEqual(375, totalFare); }
public void GivenPremiumRide_ShouldReturnInvoiceSummary() { InvoiceGenerator invoiceGenerator = new InvoiceGenerator(); string userId = "soumen"; Rides firstRide = new Rides(3.0, 5, "Premium"); Rides secondRide = new Rides(1, 1, "Normal"); List <Rides> rides = new List <Rides> { firstRide, secondRide }; RideRepository.AddRides(userId, rides); InvoiceSummary invoiceSummary = invoiceGenerator.GetInvoiceSummary(userId); InvoiceSummary expected = new InvoiceSummary { TotalNumberOfRides = 2, TotalFare = 76.0, AverageFarePerRide = 33 }; Assert.AreEqual(expected.TotalFare, invoiceSummary.TotalFare); }
public void GivenUSerId_ShouldReturnInvoiceSummary() { InvoiceGenerator invoiceGenerator = new InvoiceGenerator(); string userId = "soumen"; Rides firstRide = new Rides(3.0, 5); Rides secondRide = new Rides(1, 1); List <Rides> rides = new List <Rides> { firstRide, secondRide }; RideRepository.AddRides(userId, rides); InvoiceSummary invoiceSummary = invoiceGenerator.GetInvoiceSummary(userId); InvoiceSummary expected = new InvoiceSummary { TotalNumberOfRides = 2, TotalFare = 46, AverageFarePerRide = 23 }; object.Equals(expected, invoiceSummary); }
public void GivenUserIDandRides_WhenCalculated_ShouldReturnInvoiceSummary() { string userId = "Biru@123"; Ride[] rides = { new Ride(CabRide.NORMAL, 5.0, 1.0), new Ride(CabRide.NORMAL, 2.5, 1.5) }; Ride[] rides1 = { new Ride(CabRide.NORMAL, 2.0, 5.0), new Ride(CabRide.NORMAL, 2.5, 1.5) }; rideRepository.AddRides(userId, rides); rideRepository.AddRides(userId, rides1); InvoiceSummary retunTotal = invoiceGenerator.CalculateCabFare(rideRepository.GetRides(userId)); Assert.AreEqual(129, retunTotal.totalFare); }