コード例 #1
0
        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.");
            }
        }
コード例 #2
0
        public void Rent_Per_Hour_GetCost_WhitoutInitialize()
        {
            RentPerHour rent        = new RentPerHour();
            RentManager rentManager = new RentManager();
            //rentManager.Initialize(rent);   //Whitout Initialize
            //rent.HoursQuantity = 3;         //Whitout set any hours.
            float?totalCostResult = rentManager.GetTotalCostRent(rent);

            Assert.IsNull(totalCostResult);
        }
コード例 #3
0
        public void Rent_Per_Hour_GetCost_OneHour()
        {
            float expectedCostResult = 5;

            RentPerHour rent        = new RentPerHour();
            RentManager rentManager = new RentManager();

            rentManager.Initialize(rent);   //Initialize Rent By Hour cost
            //rent.HoursQuantity = 3;         //Whitout set any hours.
            float?totalCostResult = rentManager.GetTotalCostRent(rent);

            Assert.AreEqual(expectedCostResult, totalCostResult);
        }
コード例 #4
0
        public void Rent_Per_Hour_GetCost_ManyHours()
        {
            float expectedCostResult = 15;

            RentPerHour rent        = new RentPerHour();
            RentManager rentManager = new RentManager();

            rentManager.Initialize(rent);   //Initialize Rent By Hour cost
            rent.HoursQuantity = 3;         //Set rent on 3 hours
            float?totalCostResult = rentManager.GetTotalCostRent(rent);

            Assert.AreEqual(expectedCostResult, totalCostResult);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public void Initialize(RentPerHour rent)
 {
     rent.Cost = 5;
 }