Ejemplo n.º 1
0
        public void ShouldApplyFamilyRentalDiscountWhen3To5Rentals()
        {
            var rental  = new RentalByHour(1);
            var invoice = new Invoice();

            // 0-2 rentals. Should not apply discount.
            Assert.IsFalse(invoice.AppliesForFamilyRentalDiscount);
            invoice.AddItem(rental);
            Assert.IsFalse(invoice.AppliesForFamilyRentalDiscount);
            invoice.AddItem(rental);
            Assert.IsFalse(invoice.AppliesForFamilyRentalDiscount);

            // 3-5 rentals. Should apply discount.
            invoice.AddItem(rental);
            Assert.IsTrue(invoice.AppliesForFamilyRentalDiscount);
            invoice.AddItem(rental);
            Assert.IsTrue(invoice.AppliesForFamilyRentalDiscount);
            invoice.AddItem(rental);
            Assert.IsTrue(invoice.AppliesForFamilyRentalDiscount);

            // 6+ rentals. Should not apply discount.
            for (int i = 0; i < 5; i++)
            {
                invoice.AddItem(rental);
                Assert.IsFalse(invoice.AppliesForFamilyRentalDiscount);
            }
        }
Ejemplo n.º 2
0
        public void SetUp()
        {
            this.Client = new Client();

            this.BikeSpecifications = new BikeSpecifications(TestsConstants.BIKE_BRAND,
                                                             TestsConstants.BIKE_MODEL, TestsConstants.BIKE_COLOR);
            this.Bike = new Bike(TestsConstants.BIKE_IDENTIFICATION_CODE, this.BikeSpecifications);

            PromotionRules familyRentalRules = new PromotionRules(TestsConstants.FAMILY_RENTAL_TERMS_AND_CONDITIONS,
                                                                  new DateTime(TestsConstants.FAMILY_RENTAL_EFFECTIVE_DATE_YEAR, TestsConstants.FAMILY_RENTAL_EFFECTIVE_DATE_MONTH,
                                                                               TestsConstants.FAMILY_RENTAL_EFFECTIVE_DATE_DAY, 0, 0, 0),
                                                                  new DateTime(TestsConstants.FAMILY_RENTAL_EXPIRATON_DATE_YEAR, TestsConstants.FAMILY_RENTAL_EXPIRATON_DATE_MONTH,
                                                                               TestsConstants.FAMILY_RENTAL_EXPIRATON_DATE_DAY, 0, 0, 0));
            FamilyRentalInformation familyRentalInformation = new FamilyRentalInformation(
                TestsConstants.FAMILY_RENTAL_DISCOUNT_PERCENT, TestsConstants.FAMILY_RENTAL_MINIMUM_RENTALS,
                TestsConstants.FAMILY_RENTAL_MAXIMUM_RENTALS, familyRentalRules);

            RentalByHour rentalByHour = new RentalByHour(new Money(TestsConstants.RENTAL_BY_HOUR_AMOUNT,
                                                                   TestsConstants.RENTAL_BY_HOUR_TYPE_OF_CURRENCY));
            RentalByDay rentalByDay = new RentalByDay(new Money(TestsConstants.RENTAL_BY_DAY_AMOUNT,
                                                                TestsConstants.RENTAL_BY_DAY_TYPE_OF_CURRENCY));
            RentalByWeek rentalByWeek = new RentalByWeek(new Money(TestsConstants.RENTAL_BY_WEEK_AMOUNT,
                                                                   TestsConstants.RENTAL_BY_WEEK_TYPE_OF_CURRENCY));

            this.RentalOperator = new RentalOperator(familyRentalInformation, rentalByHour, rentalByDay, rentalByWeek);
        }
Ejemplo n.º 3
0
        public void CanCalculateRentalByHourTotalPrice()
        {
            var rental = new RentalByHour(10);

            Assert.AreEqual(10, rental.Units);
            Assert.AreEqual(5, rental.UnitPrice);
            Assert.AreEqual(50, rental.TotalPrice);
        }
Ejemplo n.º 4
0
        public void SetUp()
        {
            this.MockClient = new Mock <IClient>();

            this.MockRentalOperator = new Mock <IRentalOperator>();
            RentalBeginning rentalBeginning = new RentalBeginning(this.MockRentalOperator.Object);

            BikeSpecifications bikeSpecifications = new BikeSpecifications(TestsConstants.BIKE_BRAND,
                                                                           TestsConstants.BIKE_MODEL, TestsConstants.BIKE_COLOR);
            Bike bike = new Bike(TestsConstants.BIKE_IDENTIFICATION_CODE, bikeSpecifications);

            RentalModality rentalModality = new RentalByHour(new Money(TestsConstants.RENTAL_BY_HOUR_AMOUNT,
                                                                       TestsConstants.RENTAL_BY_HOUR_TYPE_OF_CURRENCY));

            this.Rental = new Rental(this.MockClient.Object, rentalBeginning, bike, rentalModality);
        }
Ejemplo n.º 5
0
        public void UpdateProperties()
        {
            RentalByHour rentalByHour = new RentalByHour(new Money(TestsConstants.RENTAL_BY_HOUR_AMOUNT * 2,
                                                                   TestsConstants.RENTAL_BY_HOUR_TYPE_OF_CURRENCY));
            RentalByDay rentalByDay = new RentalByDay(new Money(TestsConstants.RENTAL_BY_DAY_AMOUNT * 2,
                                                                TestsConstants.RENTAL_BY_DAY_TYPE_OF_CURRENCY));
            RentalByWeek rentalByWeek = new RentalByWeek(new Money(TestsConstants.RENTAL_BY_WEEK_AMOUNT * 2,
                                                                   TestsConstants.RENTAL_BY_WEEK_TYPE_OF_CURRENCY));

            this.RentalOperator.UpdateCurrentRentalByHourModality(rentalByHour);
            this.RentalOperator.UpdateCurrentRentalByDayModality(rentalByDay);
            this.RentalOperator.UpdateCurrentRentalByWeekModality(rentalByWeek);
            Assert.AreEqual(rentalByHour, this.RentalOperator.CurrentRentalByHourModality);
            Assert.AreEqual(rentalByDay, this.RentalOperator.CurrentRentalByDayModality);
            Assert.AreEqual(rentalByWeek, this.RentalOperator.CurrentRentalByWeekModality);

            FamilyRentalInformation familyRentalInformation = new FamilyRentalInformation(
                TestsConstants.FAMILY_RENTAL_DISCOUNT_PERCENT, 6, 10, this.FamilyRentalRules);

            this.RentalOperator.UpdateCurrentFamilyRentalInformation(familyRentalInformation);
            Assert.AreEqual(familyRentalInformation, this.RentalOperator.CurrentFamilyRentalInformation);
        }
Ejemplo n.º 6
0
 public void SetUp()
 {
     this.CostPerUnitOfTime = new Money(TestsConstants.RENTAL_BY_HOUR_AMOUNT,
                                        TestsConstants.RENTAL_BY_HOUR_TYPE_OF_CURRENCY);
     this.RentalByHour = new RentalByHour(this.CostPerUnitOfTime);
 }
Ejemplo n.º 7
0
        public void HourCalculateCostPrice5Hours2()
        {
            IRental rental = new RentalByHour(5m, 2);

            Assert.AreEqual(10m, rental.CalculateCost());
        }