示例#1
0
        public void givenUserId_WhenAbsent_ShouldThrowAnException()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);
            var result = Assert.Throws <CabInvoiceException>(() => invoiceGenerator.GetUserInvoice(1));

            Assert.AreEqual(CabInvoiceException.ExceptionType.INVALID_USER_ID, result.type);
        }
示例#2
0
        public void GivenUserIDGetsTotalFare()
        {
            double actual   = invoice.GetUserInvoice("1");
            double expected = 50.0;

            Assert.AreEqual(expected, actual);
        }
        public void GivenUserId_WhenAbsent_Should_Return_CabInvoiceException()
        {
            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);

            var exception = Assert.Throws <CabInvoiceException>(() => invoiceGenerator.GetUserInvoice(1));

            Assert.AreEqual(CabInvoiceException.Type.INVALID_USER_ID, exception.type);
        }
示例#4
0
        public void givenUserId_WhenCheckedIfPresent_ShouldReturnInvoiceInfo()
        {
            rideList = new List <Ride> {
                new Ride(5, 20), new Ride(3, 15), new Ride(2, 10)
            };
            double expectedFare    = 145;
            int    expectedRides   = 3;
            double expectedAverage = expectedFare / expectedRides;

            invoiceGenerator.AddRides(1, rideList);
            CabInfo info = invoiceGenerator.GetUserInvoice(1);

            Assert.IsTrue(info.numberOfRides == expectedRides && info.totalFare == expectedFare && info.averageFare == expectedAverage);
        }
        public void GivenUserId_WhenPresent_Should_Return_CabInvoiceSummary()
        {
            rideList = new List <Ride> {
                new Ride(5, 20), new Ride(3, 15), new Ride(2, 10)
            };
            double expectedFare    = 145;
            int    expectedRides   = 3;
            double expectedAverage = expectedFare / expectedRides;

            invoiceGenerator = new InvoiceGenerator(RideType.NORMAL);

            invoiceGenerator.AddRides(1, rideList);
            InvoiceData data = invoiceGenerator.GetUserInvoice(1);

            Assert.IsTrue(data.noOfRides == expectedRides && data.totalFare == expectedFare && data.averageFare == expectedAverage);
        }