public void SetUp() { BikeSpecifications bikeSpecifications = new BikeSpecifications(TestsConstants.BIKE_BRAND, TestsConstants.BIKE_MODEL, TestsConstants.BIKE_COLOR); this.Bike = new Bike(TestsConstants.BIKE_IDENTIFICATION_CODE, bikeSpecifications); }
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 ProvideFamilyRentalWithDifferentAmountOfElementsThrowsAmountOfClientsAndBikesAndUnitsOfTimeDoNotMatchException() { 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); IList <Bike> bikes = new List <Bike>(); bikes.Add(this.Bike); bikes.Add(bike2); bikes.Add(bike3); IList <UnitOfTime> unitsOfTimes = new List <UnitOfTime>(); unitsOfTimes.Add(UnitOfTime.Hour); unitsOfTimes.Add(UnitOfTime.Hour); Assert.That(() => this.RentalOperator.ProvideFamilyRental(mother, clients, bikes, unitsOfTimes), Throws.TypeOf <AmountOfClientsAndBikesAndUnitsOfTimeDoNotMatchException>()); }
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 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); }