コード例 #1
0
        public void Less_Than_10()
        {
            //arrange
            IDiscount target = GetObject();

            //assert
            Assert.AreEqual(5, target.ApplyDiscount(5), "Error value 100");
            Assert.AreEqual(0, target.ApplyDiscount(0), "Error value 10");
        }
コード例 #2
0
        public void Above_100()
        {
            //arrange
            IDiscount target     = GetObject();
            decimal   result_200 = 100;
            decimal   result_500 = 250;
            //act
            decimal result1 = target.ApplyDiscount(200);
            decimal result2 = target.ApplyDiscount(500);

            //assert
            Assert.AreEqual(result_200, result1, "Error value 100");
            Assert.AreEqual(result_500, result2, "Error value 500");
        }
コード例 #3
0
        public void las_100()
        {
            //arrange
            IDiscount target    = GetObject();
            decimal   result_50 = 45;
            decimal   result_95 = 90;
            //act
            decimal result1 = target.ApplyDiscount(200);
            decimal result2 = target.ApplyDiscount(500);

            //assert
            Assert.AreEqual(result_50, result1, "Error value 100");
            Assert.AreEqual(result_95, result2, "Error value 500");
        }
コード例 #4
0
        public void NegativeVal()
        {
            //arrange
            IDiscount target = GetObject();

            target.ApplyDiscount(-10);
        }
コード例 #5
0
        public void Between_100_10()
        {
            //arrange
            IDiscount target     = GetObject();
            decimal   result_100 = 95;
            decimal   result_10  = 5;
            decimal   result_50  = 45;

            //act
            decimal result1 = target.ApplyDiscount(100);
            decimal result2 = target.ApplyDiscount(10);
            decimal result3 = target.ApplyDiscount(50);

            //assert
            Assert.AreEqual(result_100, result1, "Error value 100");
            Assert.AreEqual(result_10, result2, "Error value 10");
            Assert.AreEqual(result_50, result2, "Error value 50");
        }
コード例 #6
0
        public Decimal CalculatePayPeriodCost(Person person)
        {
            Decimal cost;
            Decimal monthlyCost;

            if (person is Employee)
            {
                cost = _plan.EmployeeCost;
            }
            else
            {
                cost = _plan.DependentCost;
            }

            monthlyCost = cost / _cycle.NumPeriods;

            if (_discount != null)
            {
                return(_discount.ApplyDiscount(person, monthlyCost));
            }

            return(monthlyCost);
        }
コード例 #7
0
        public decimal SumarizeProducts(IEnumerable <CartLine> products)
        {
            var total = products.Sum(x => x.Product.Price * x.Quantity);

            return(discounter.ApplyDiscount(total));
        }
コード例 #8
0
 public override double GetPrice()
 {
     return(discount.ApplyDiscount(base.GetPrice()));
 }
コード例 #9
0
 public decimal TotalSumWithDiscount(decimal sum)
 {
     return(discount.ApplyDiscount(sum));
 }
 public decimal SumOfPrice(IEnumerable <Book> books)
 {
     return(books.Sum(x => discount.ApplyDiscount(x.Price)));
 }
コード例 #11
0
 public void ApplyDiscount(IDiscount discount)
 {
     discount.ApplyDiscount(this);
 }
コード例 #12
0
 public void ApplyDiscount(IDiscount discount)
 {
     GrandTotalPrice = discount.ApplyDiscount(this);
     _discounts.Add(discount.Name);
 }
コード例 #13
0
 public override decimal GetSumWithDiscount()
 {
     return(discount.ApplyDiscount(GetSum()));
 }