public void Rent_Per_Family_GetCost_3rents() { float expectedCostResult = (float)(160 * (0.7)); RentPerWeek rent1 = new RentPerWeek(); RentPerWeek rent2 = new RentPerWeek(); RentPerDay rent3 = new RentPerDay(); rent3.DaysQuantity = 2; RentManager rentManager = new RentManager(); rentManager.Initialize(rent1); //Initialize Rent By Week cost rentManager.Initialize(rent2); //Initialize Rent By Week cost rentManager.Initialize(rent3); //Initialize Rent By Week cost FamilyRent rent = new FamilyRent(); rentManager.Initialize(rent); List <Rent> rents = new List <Rent> { rent1, rent2, rent3 }; rent.AddRents(rents); /*rent.AddRent(rent1); * rent.AddRent(rent2); * rent.AddRent(rent3);*/ float?totalCostResult = rentManager.FamilyRent_GetTotalAmount(rent); Assert.AreEqual(expectedCostResult, totalCostResult); }
public void Rent_Per_Family_GetCost_6rents() { RentPerHour rent1 = new RentPerHour(); RentPerHour rent2 = new RentPerHour(); RentManager rentManager = new RentManager(); rentManager.Initialize(rent1); //Initialize Rent rentManager.Initialize(rent2); //Initialize Rent FamilyRent rent = new FamilyRent(); rentManager.Initialize(rent); rent.AddRent(rent1); //Adding 6 rents rent.AddRent(rent2); rent.AddRent(rent1); rent.AddRent(rent2); rent.AddRent(rent1); rent.AddRent(rent2); try { float?totalCostResult = rentManager.FamilyRent_GetTotalAmount(rent); } catch (Exception ex) { Assert.AreEqual <string>(ex.Message, "Family Rental, need include from 3 to 5 Rentals. This Family Rental only have 6 rents."); } }
public float?FamilyRent_GetTotalAmount(FamilyRent familyRent) { if ((familyRent.Count() < 3) || (familyRent.Count() > 5)) { throw new ArgumentException("Family Rental, need include from 3 to 5 Rentals. This Family Rental only have " + familyRent.Count().ToString() + " rents."); } return(familyRent.TotalCost()); }
public void AddZeroRentals_ToFamilyRental_ShouldThrowAnException() { var familyRent = new FamilyRent(); var rentals = new List <Rental>(); Assert.Throws <FamilyRentException>(() => familyRent.AddRentals(null)); Assert.Throws <FamilyRentException>(() => familyRent.AddRentals(rentals)); }
public void AddTwoRentals_ToFamilyRental_ShouldThrowAnException() { var dayRent = GetDayRent(20, 5); var hourRent = GetHourRent(5, 5); var familyRent = new FamilyRent(); var rentals = new List <Rental> { dayRent, hourRent }; Assert.Throws <FamilyRentException>(() => familyRent.AddRentals(rentals)); }
public void RentForFamilyRental() { var dayRent = GetDayRent(20, 5); var hourRent = GetHourRent(5, 5); var weekRent = GetWeekRent(60, 5); var familyRent = new FamilyRent(); var rentals = new List <Rental> { dayRent, hourRent, weekRent }; familyRent.AddRentals(rentals); Assert.IsTrue(familyRent.Rentals.Count < 6); Assert.IsTrue(familyRent.Rentals.Count > 2); Assert.IsTrue(familyRent.CalculateRent() == (20 * 5 + 5 * 5 + 60 * 5) * 0.7m); }
public void Rent_Per_Family_GetCost_5rents() { float expectedCostResult = (float)((20 + 15 + 20 + 5 + 5) * (0.7)); RentPerHour rent1 = new RentPerHour(); RentPerHour rent2 = new RentPerHour(); RentPerDay rent3 = new RentPerDay(); RentPerHour rent4 = new RentPerHour(); RentPerHour rent5 = new RentPerHour(); rent1.HoursQuantity = 4; rent2.HoursQuantity = 3; RentManager rentManager = new RentManager(); rentManager.Initialize(rent1); //Initialize Rent rentManager.Initialize(rent2); //Initialize Rent rentManager.Initialize(rent3); //Initialize Rent rentManager.Initialize(rent4); //Initialize Rent rentManager.Initialize(rent5); //Initialize Rent FamilyRent rent = new FamilyRent(); rentManager.Initialize(rent); List <Rent> rents = new List <Rent> { rent1, rent2, rent3 }; rent.AddRents(rents); rent.AddRent(rent4); rent.AddRent(rent5); float?totalCostResult = rentManager.FamilyRent_GetTotalAmount(rent); Assert.AreEqual(expectedCostResult, totalCostResult); }
/* * public float? GetTotalCostRent(RentPerWeek rent) * { * return rent.TotalCost(); * } * * public float? GetTotalCostRent(RentPerDay rent) * { * return rent.TotalCost(); * } * * public float? GetTotalCostRent(FamilyRent rent) * { * return rent.TotalCost(); * } */ public void FamilyRent_AddRent(FamilyRent familyRent, Rent rent) { familyRent.AddRent(rent); }
public void Initialize(FamilyRent rent) { rent.Discount = 30; }