public void SetUp() { this.MockClient = new Mock <IClient>(); this.MockRental1 = new Mock <IRental>(); this.MockRental2 = new Mock <IRental>(); this.MockRental3 = new Mock <IRental>(); this.MockRental4 = new Mock <IRental>(); IList <IRental> rentals = new List <IRental>(); rentals.Add(this.MockRental1.Object); rentals.Add(this.MockRental2.Object); rentals.Add(this.MockRental3.Object); rentals.Add(this.MockRental4.Object); 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); this.FamilyRental = new FamilyRental(this.MockClient.Object, familyRentalInformation, rentals); }
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); }
public void ProvideFamilyRentalWithAmountsOk() { // I force the 3 and 5 to control the amount of rentals allowed and not depend on the constants FamilyRentalInformation familyRentalInformation = new FamilyRentalInformation( TestsConstants.FAMILY_RENTAL_DISCOUNT_PERCENT, 3, 5, this.FamilyRentalRules); this.RentalOperator.UpdateCurrentFamilyRentalInformation(familyRentalInformation); IClient father = new Client(); IClient mother = new Client(); IClient son = new Client(); IClient daughter = new Client(); IList <IClient> clients = new List <IClient>(); clients.Add(mother); clients.Add(father); clients.Add(son); clients.Add(daughter); Bike bike2 = new Bike("YGR496", this.BikeSpecifications); BikeSpecifications bikeSpecifications3 = new BikeSpecifications("Trek", "Madone", "Green"); Bike bike3 = new Bike("JWT764", bikeSpecifications3); BikeSpecifications bikeSpecifications4 = new BikeSpecifications("Santa Cruz", "V10", "Brown"); Bike bike4 = new Bike("MTN858", bikeSpecifications4); IList <Bike> bikes = new List <Bike>(); bikes.Add(this.Bike); bikes.Add(bike2); bikes.Add(bike3); bikes.Add(bike4); IList <UnitOfTime> unitsOfTimes = new List <UnitOfTime>(); unitsOfTimes.Add(UnitOfTime.Hour); unitsOfTimes.Add(UnitOfTime.Hour); unitsOfTimes.Add(UnitOfTime.Day); unitsOfTimes.Add(UnitOfTime.Day); FamilyRental familyRental = this.RentalOperator.ProvideFamilyRental(mother, clients, bikes, unitsOfTimes); Assert.AreEqual(mother, familyRental.Client); Assert.AreEqual(this.RentalOperator.CurrentFamilyRentalInformation, familyRental.Information); for (int i = 0; i < clients.Count; i++) { Assert.AreEqual(clients[i], familyRental.Rentals[i].Client); Assert.AreEqual(bikes[i], familyRental.Rentals[i].Bike); Assert.AreEqual(unitsOfTimes[i], familyRental.Rentals[i].Modality.UnitOfTime); } }
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); }