예제 #1
0
        public void FamilyRentalCalculateLessThan3()
        {
            FamilyRentalPack family = new FamilyRentalPack(new ClosedRangeValidator <int>(3, 5), new StandardDiscount(30m));

            family.AddRental(new RentalByHour(5m, 1));
            family.AddRental(new RentalByHour(5m, 2));

            Assert.Throws <InvalidOperationException>(delegate { family.CalculateCost(); });
        }
예제 #2
0
        public void FamilyRentalWithOverflow()
        {
            FamilyRentalPack family = new FamilyRentalPack(new ClosedRangeValidator <int>(3, 5), new StandardDiscount(30m));

            family.AddRental(new RentalByHour(decimal.MaxValue, int.MaxValue));
            family.AddRental(new RentalByDay(20m, 1));
            family.AddRental(new RentalByWeek(60m, 1));

            Assert.Throws <InvalidOperationException>(delegate { family.CalculateCost(); });
        }
예제 #3
0
        public void FamilyRentalCalculate1Hour1Day1Week()
        {
            FamilyRentalPack family = new FamilyRentalPack(new ClosedRangeValidator <int>(3, 5), new StandardDiscount(30m));

            family.AddRental(new RentalByHour(5m, 1));
            family.AddRental(new RentalByDay(20m, 1));
            family.AddRental(new RentalByWeek(60m, 1));

            Assert.AreEqual(59.5m, family.CalculateCost());
        }