Пример #1
0
        public void IsOver1YearTest()
        {
            var isOver1Year = _util.IsOver1Year(DateTime.Today.AddYears(-1).AddDays(-1));
            Assert.IsTrue(isOver1Year);

            isOver1Year = _util.IsOver1Year(DateTime.Today.AddYears(-1));
            Assert.IsTrue(isOver1Year);

            isOver1Year = _util.IsOver1Year(DateTime.Today.AddYears(-1).AddDays(1));
            Assert.IsFalse(isOver1Year);
        }
Пример #2
0
        public Discount LongServiceDiscount(CustomerAccount account)
        {
            decimal discountValue;
            var     discountType = DiscountType.LongServiceDiscount;

            if (_util.IsOver3Years(account.CreatedOn))
            {
                discountValue = 1;
            }
            else if (_util.IsOver2Years(account.CreatedOn))
            {
                discountValue = 0.5M;
            }
            else
            {
                if (_util.IsOver1Year(account.CreatedOn))
                {
                    discountValue = 0.25M;
                }
                else
                {
                    discountType  = DiscountType.None;
                    discountValue = 0;
                }
            }

            return(new Discount
            {
                DiscountType = discountType,
                DiscountValue = discountValue
            });
        }