Пример #1
0
        public void givenMinimumDistanceAndMinimumTime_WhenCalculated_ShouldReturnMinimumFare()
        {
            double distance = 0.2;
            int    time     = 1;
            double result   = invoiceGenerator.CalculateFare(new Ride(distance, time));

            Assert.AreEqual(result, 5);
        }
Пример #2
0
        public void GivenDistanceAndTime_shouldReturn_TotalFare()
        {
            double distance = 2.0;
            int    time     = 5;
            double fare     = invoiceGenerator.CalculateFare(InvoiceGenerator.Journey.NORMAL, distance, time);

            Assert.AreEqual(25, fare);
        }
Пример #3
0
        public void GivenDistanceAndTimeReturnsFare()
        {
            double distance     = 2.0;
            int    time         = 30;
            double fareActual   = invoice.CalculateFare(distance, time);
            double fareExpected = 50;

            Assert.AreEqual(fareExpected, fareActual);
        }
Пример #4
0
        public void GivenDistanceAndTime_ShouldReturn_TotalFare()
        {
            double expected = 25;
            double result   = InvoiceGenerator.CalculateFare(2, 5, RideType.NORMAL);

            Assert.AreEqual(expected, result);
        }
        public void GivenWrongRideParameters_WhenRead_ShouldReturn_Exception_INVALID_RIDE_TYPE()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            var exception = Assert.Throws <CabInvoiceException>(() => invoiceGenerator.CalculateFare(-45, -3));

            Assert.AreEqual(CabInvoiceException.ExceptionType.INVALID_DISTANCE, exception.etype);
        }
Пример #6
0
        //Test case 4 - Should return total fare on having multiple rides
        public void Given_MultipleNoOfRides_Should_Return_TotalFare()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            rides            = new Ride[] { new Ride(10, 60), new Ride(5, 30), new Ride(3, 20) };
            double fare = invoiceGenerator.CalculateFare(rides);

            Assert.AreEqual(290, fare);
        }
        public void WhenGivenDistanceAndTimeReturnFare()
        {
            Ride   ride      = new Ride(RideType.NORMAL, 5, 15);
            double totalFare = generator.CalculateFare(ride);
            double expected  = 65;

            Assert.AreEqual(expected, totalFare);
        }
Пример #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome To Cab Invoice Generator");
            InvoiceGenerator invoiceGenerator = new InvoiceGenerator(RideType.PREMIUM);
            double           fare             = invoiceGenerator.CalculateFare(2.0, 5);

            Console.WriteLine($"Fare : {fare}");
        }
Пример #9
0
        public void CalculateFare_IfNullRides_ThrowsException()
        {
            var invoiceGenerator = new InvoiceGenerator();

            var exception = Assert.Throws <CabInvoiceException>(() => invoiceGenerator.CalculateFare(null));

            Assert.That(exception.type, Is.EqualTo(CabInvoiceException.ExceptionType.NULL_RIDES));
        }
Пример #10
0
        public void CalculateFare_IfInvalidTime_ThrowsException()
        {
            var invoiceGenerator = new InvoiceGenerator();

            var exception = Assert.Throws <CabInvoiceException>(() => invoiceGenerator.CalculateFare(1.0, -1));

            Assert.That(exception.type, Is.EqualTo(CabInvoiceException.ExceptionType.INVALID_TIME));
        }
Пример #11
0
        public void CalculateFare_IfValidParameters_ReturnsFare(RideType rideType, double expectedFare)
        {
            var invoiceGenerator = new InvoiceGenerator(rideType);

            var result = invoiceGenerator.CalculateFare(2.0, 1);

            Assert.That(result, Is.EqualTo(expectedFare));
        }
Пример #12
0
        public void GivenMultipleRide_ShouldReturn_TotalNoRides_Fare_AverageFarePerRide()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            Ride[]         rides                   = { new Ride(2.0, 5), new Ride(0.1, 3) };
            InvoiceSummary enhancedSummary         = invoiceGenerator.CalculateFare(rides);
            InvoiceSummary expectedEnhancedSummary = new InvoiceSummary(2, 30);

            Assert.AreEqual(expectedEnhancedSummary, enhancedSummary);
        }
Пример #13
0
        //Test case 1 - Should return cab fare on giving valid inputs
        public void Given_Valid_DistanceAndTime_Should_Return_CabFare()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            double distance = 10; // in Km
            int    time     = 60; // in minutes
            double fare     = invoiceGenerator.CalculateFare(distance, time);

            Assert.AreEqual(160.0d, fare);
        }
Пример #14
0
        public void GivenMultipleRideShouldReturnInvoiceSummary()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            Ride[]         rides           = { new Ride(2.0, 5), new Ride(0.1, 5) };
            InvoiceSummary summary         = invoiceGenerator.CalculateFare(rides);
            InvoiceSummary expectedSummary = new InvoiceSummary(2, 35.0);

            NUnit.Framework.Assert.AreEqual(expectedSummary.GetType(), summary.GetType());
        }
Пример #15
0
        public void GivenDistanceAndTime_ShouldReturnTotalFare()
        {
            InvoiceGenerator invoiceGenerator = new InvoiceGenerator();
            double           distance         = 2.0;
            int    time = 5;
            double fare = invoiceGenerator.CalculateFare(distance, time, "Normal");

            Assert.AreEqual(25, fare);
        }
Пример #16
0
        public void GivenMultipleRides_ShouldReturn_InvoiceSummary()
        {
            double expected = 45.0;

            Ride[]         ridesTestObj = { new Ride(2.0, 5, RideType.NORMAL), new Ride(0.1, 1, RideType.PREMIUM) };
            InvoiceSummary result       = InvoiceGenerator.CalculateFare(ridesTestObj);

            Assert.AreEqual(expected, result.totalFare);
        }
Пример #17
0
        public void GivenLessDistanceAndTime_ShouldReturnMinFare()
        {
            InvoiceGenerator invoiceGenerator = new InvoiceGenerator();
            double           distance         = 0.1;
            int    time = 1;
            double fare = invoiceGenerator.CalculateFare(distance, time, "Normal");

            Assert.AreEqual(5, fare);
        }
Пример #18
0
        public void GivenMultipleRides_WhenInvoiceGenerator_thenShouldReturn_InvoiceSummary()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            Ride[]         rides           = { new Ride(2.0, 5), new Ride(0.1, 1) };
            InvoiceSummary invoiceSummary  = invoiceGenerator.CalculateFare(rides);
            InvoiceSummary expectedSummary = new InvoiceSummary(2, 30.0);

            Assert.AreEqual(expectedSummary, invoiceSummary);
        }
Пример #19
0
        public void GivenNormalMultipleRideShouldReturnInvoiceSummary()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            Ride[]         rides           = { new Ride(2.0, 5), new Ride(2.0, 5) };
            InvoiceSummary summary         = invoiceGenerator.CalculateFare(rides);
            InvoiceSummary expectedSummary = new InvoiceSummary(2, 50.0);

            Assert.AreEqual(expectedSummary, summary);
        }
Пример #20
0
        public void GivenMutipleEnhancedInvoiceShouldReturnTotalRidesTotalFareAverageFarePerRide()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            Ride[]         rides                   = { new Ride(2.0, 5), new Ride(2.0, 5) };
            InvoiceSummary enhancedSummary         = invoiceGenerator.CalculateFare(rides);
            InvoiceSummary expectedEnhancedSummary = new InvoiceSummary(2, 50);

            Assert.AreEqual(expectedEnhancedSummary, enhancedSummary);
        }
Пример #21
0
        public void GivenPremiumRides_ShouldReturnTotalFare()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.PREMIUM);
            Ride[]         rides  = { new Ride(2, 5), new Ride(2, 1) };
            InvoiceSummary result = invoiceGenerator.CalculateFare(rides);
            InvoiceSummary expectedInvoiceSummary = new InvoiceSummary(2, 72);

            Assert.AreEqual(expectedInvoiceSummary, result);
        }
Пример #22
0
        public void GivenMultipleRides_ShouldReturnInvoiceSummary()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            Ride[]         rides  = { new Ride(2, 5), new Ride(2, 1) };
            InvoiceSummary result = invoiceGenerator.CalculateFare(rides);
            InvoiceSummary expectedInvoiceSummary = new InvoiceSummary(2, 46);

            Assert.AreEqual(expectedInvoiceSummary, result);
        }
Пример #23
0
        public void CalculateFare_IfMultipleRidesPassed_ReturnsInvoiceSummary(RideType rideType, double expectedFare)
        {
            Ride[] rides            = { new Ride(1.0, 1), new Ride(2.0, 1) };
            var    invoiceGenerator = new InvoiceGenerator(rideType);

            var result   = invoiceGenerator.CalculateFare(rides);
            var expected = new InvoiceSummary(2, expectedFare);

            Assert.That(result, Is.EqualTo(expected));
        }
Пример #24
0
        public void GivenPremiumDistanceAndTimeShouldReturnTotalFare()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.PREMIUM);
            double distance = 2.0;
            int    time     = 5;
            double fare     = invoiceGenerator.CalculateFare(distance, time);
            double expected = 40;

            Assert.AreEqual(expected, fare);
        }
Пример #25
0
        public void GivenNormalDistanceAndTimeShouldReturnTotalFare()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            double distance = 2.0;
            int    time     = 5;
            double fare     = invoiceGenerator.CalculateFare(distance, time);
            double expected = 25;

            Assert.AreEqual(expected, fare);
        }
Пример #26
0
        public void GivenDistanceAndTimeReturnTotalFare()
        {
            invoiceGenerator = new InvoiceGenerator();
            double distance = 2.0;
            int    time     = 5;
            double fare     = invoiceGenerator.CalculateFare(distance, time);
            double expected = 25;

            Assert.AreEqual(expected, fare);
        }
Пример #27
0
        public void GivenMultipleRidesShouldReturnEnhancedInvoice()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            Ride[] rides = { new Ride(2.0, 5), new Ride(0.1, 1) };

            InvoiceSummary summary         = invoiceGenerator.CalculateFare(rides);
            InvoiceSummary expectedSummary = new InvoiceSummary(2, 30.0, 15);

            Assert.AreEqual(expectedSummary, summary);
        }
Пример #28
0
        public void GivenDistanceAndTime_WhenNormalRide_ShouldReturnFare()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            double distance = 2;
            int    time     = 2;
            double fare     = invoiceGenerator.CalculateFare(distance, time);
            double expected = 22;

            Assert.AreEqual(expected, fare);
        }
Пример #29
0
        public void GivenDistanceTime_ShouldReturnTotalFare()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            float distance     = 2;
            float time         = 5;
            float fare         = invoiceGenerator.CalculateFare(distance, time);
            float expectedFare = 25;

            Assert.AreEqual(expectedFare, fare);
        }
Пример #30
0
        public void GivenDistanceAndTime_WhenInvoiceGenerator_ThenShouldReturnTotalFareForPremiumRide()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.PREMIUM);
            double distance = 4.0;
            int    time     = 7;
            double fare     = invoiceGenerator.CalculateFare(distance, time);
            double expected = 74;

            Assert.AreEqual(expected, fare);
        }