Example #1
0
        public void GivenMultipleRides_ShouldReturnInvoiceSummaryWithAvg()
        {
            // Arrange
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            Ride[] rides = { new Ride(2.0, 5), new Ride(0.1, 1) };
            // Act
            InvoiceSummary invoiceSummary = invoiceGenerator.CalculateAvgFare(rides);
            // if both the objects are equal then get the same HashCode for both the objects
            var            resultHashCode         = invoiceSummary.GetHashCode();
            InvoiceSummary expectedInvoiceSummary = new InvoiceSummary(30.0, 2, 15.0);
            var            resulExpectedHashCode  = expectedInvoiceSummary.GetHashCode();

            // Assert
            Assert.AreEqual(expectedInvoiceSummary, invoiceSummary);
        }
Example #2
0
        public void GivenUserId_ShouldReturnInvoiceSummary()
        {
            // Arrange
            // initialising the object of the invoice generator class
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            // Creating the object of the ride repository
            RideRepository repository = new RideRepository();
            // Initialising the user ID
            string userID = "akash";

            // Initialising the ride array with details of the ride
            Ride[] rides = { new Ride(2.0, 5), new Ride(0.1, 1) };
            // Adding the ride data for the user to the ride repository
            repository.AddRide(userID, rides);
            // Getting the ride data from the ride repository class using the user ID
            Ride[] rideData = repository.GetRides(userID);
            // Getting the invoice summary when passing the ride Data
            InvoiceSummary invoiceSummary = invoiceGenerator.CalculateAvgFare(rideData);
            // Expected value of the Invoice Summary
            InvoiceSummary expectedInvoiceSummary = new InvoiceSummary(30.0, 2, 15.0);

            // Asserting the comparison between the expected and actual invoice summary
            Assert.AreEqual(expectedInvoiceSummary, invoiceSummary);
        }