Example #1
0
        public void MotorHome_list_should_be_created_for_motorhomes()
        {
            var car     = new MotorHome();
            var factory = PricingFactory.Create();

            var policy = factory.GetPolicyFor(car);

            Assert.IsInstanceOfType(policy, typeof(MotorHomePricing));
        }
Example #2
0
        public void Basic_list_should_be_created_for_basic_cars()
        {
            var car     = new PopularFamilyCar();
            var factory = PricingFactory.Create();

            var policy = factory.GetPolicyFor(car);

            Assert.IsInstanceOfType(policy, typeof(PopularFamilyCarPricing));
        }
Example #3
0
        public void Invalid_items_should_not_be_included_in_total_price()
        {
            var request = BuildRentalRequest(new PopularFamilyCar(), 4, 600);

            request.AddAccessory(new Refrigerator());

            var pricingFactory = PricingFactory.Create();
            var rental         = new RentalStore(pricingFactory).Rent(request);

            Assert.AreEqual(500M, rental.TotalPrice);
        }
Example #4
0
        public void Rental_prices_should_account_for_days_and_kilometers()
        {
            IVehicle carType = new PopularFamilyCar();
            var      request = BuildRentalRequest(new PopularFamilyCar(), 4, 600);
            var      factory = PricingFactory.Create();

            var rental = new RentalStore(factory).Rent(request);

            Assert.AreEqual(4, rental.Days);
            Assert.AreEqual(200M, rental.TotalDailyPrice);
            Assert.AreEqual(300M, rental.EstimatedTotalKmPrice);
            Assert.AreEqual(500M, rental.TotalPrice);
        }
Example #5
0
        public void Rental_prices_should_account_for_valid_additional_items()
        {
            var request = BuildRentalRequest(new PopularFamilyCar(), 4, 600);

            request.AddAccessory(new CarSeat());

            var pricingFactory = PricingFactory.Create();
            var rental         = new RentalStore(pricingFactory).Rent(request);

            Assert.AreEqual(4, rental.Days);
            Assert.AreEqual(200M, rental.TotalDailyPrice);
            Assert.AreEqual(300M, rental.EstimatedTotalKmPrice);
            Assert.AreEqual(65M, rental.AdditionalItemsPrice);
            Assert.AreEqual(565M, rental.TotalPrice);
        }