public TestIncentiveRepository() {

            //percent off coupons
            Incentive i = new Incentive("1", new PercentOffOrderCoupon(10), DateTime.Now.AddDays(1));
            incentives.Add(i);

            i = new Incentive("2", new PercentOffOrderCoupon(20), DateTime.Now.AddDays(1));
            incentives.Add(i);

            i = new Incentive("3", new PercentOffOrderCoupon(30), DateTime.Now.AddDays(1));
            incentives.Add(i);
            
            //this will always be expired
            i = new Incentive("EXPIRED", new PercentOffOrderCoupon(30), DateTime.Now);
            incentives.Add(i);


            i = new Incentive("INVALID_MINITEMS", new PercentOffOrderCoupon(10), DateTime.Now.AddDays(1));
            i.MinimumItems = 1000;
            incentives.Add(i);

            i = new Incentive("INVALID_MINPURCHASE", new PercentOffOrderCoupon(10), DateTime.Now.AddDays(1));
            i.MininumPurchase = 10000000;
            incentives.Add(i);

            i = new Incentive("10DOLLARSOFF", new AmountOffOrderCoupon(10), DateTime.Now.AddDays(1));
            incentives.Add(i);

            i = new Incentive("8DOLLARSOFFSKU1", new AmountOffItemCoupon(8, "SKU1"), DateTime.Now.AddDays(1));
            incentives.Add(i);

            i = new Incentive("50PERCENTOFFSKU1", new PercentOffItemCoupon(50, "SKU1"), DateTime.Now.AddDays(1));
            incentives.Add(i);

        }
Exemplo n.º 2
0
        public void Incentive_Should_Have_Code_Coupon_Expiration() {
            
            ICoupon coupon=new PercentOffOrderCoupon(10);

            Incentive i = new Incentive("XYZ", coupon, DateTime.Today.AddDays(1));
            Assert.AreEqual("XYZ", i.Code);
            Assert.AreEqual(coupon, i.Coupon);
            Assert.IsFalse(i.IsExpired);
        }
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            bool result = false;

            if (obj.GetType() == typeof(Incentive))
            {
                Incentive compareTo = (Incentive)obj;
                result = compareTo.Code.Equals(this.Code, StringComparison.InvariantCultureIgnoreCase);
            }

            return(result);
        }
Exemplo n.º 4
0
        public void Incentive_Should_Throw_When_MinItems_IsMore_Than_OrderItems() {
            Order order = GetTestOrder();

            Incentive i = new Incentive("XYZ", new PercentOffOrderCoupon(10), DateTime.Now.AddDays(1));
            i.MinimumItems = 5;

            bool thrown = false;
            try {
                i.ValidateUse(order);
            }
            catch(Exception x) {
                thrown = true;
                Assert.AreEqual("There is a minimum of " + i.MinimumItems.ToString() + " items required",x.Message);
            }

            Assert.IsTrue(thrown);

        }
Exemplo n.º 5
0
 public void Incentive_Should_Have_MinimumItems_MinAmount_MustHaveProducts() {
     Incentive i = new Incentive("XYZ", new PercentOffOrderCoupon(10), DateTime.Now);
     Assert.AreEqual(0, i.MinimumItems);
     Assert.AreEqual(0, i.MininumPurchase);
     Assert.AreEqual(0, i.MustHaveProducts.Length);
 }
Exemplo n.º 6
0
        public void Incentive_Should_Throw_When_MustHaveProducts_Include_SKU10000() {
            Order order = GetTestOrder();

            Incentive i = new Incentive("XYZ", new PercentOffOrderCoupon(10), DateTime.Now.AddDays(1));
            i.MustHaveProducts =new string[]{"SKU10000"};
            bool thrown = false;
            try {
                i.ValidateUse(order);
            }
            catch (Exception x) {
                thrown = true;
                Assert.AreEqual("This coupon is not valid for the items you've selected", x.Message);
            }

            Assert.IsTrue(thrown);
        }
Exemplo n.º 7
0
        public void Incentive_Should_NotThrow_When_MustHaveProducts_Include_SKU1() {
            Order order = GetTestOrder();

            Incentive i = new Incentive("XYZ", new PercentOffOrderCoupon(10), DateTime.Now.AddDays(1));
            i.MustHaveProducts = new string[] { "SKU1" };
            bool thrown = false;
            try {
                i.ValidateUse(order);
            }
            catch {
                thrown = true;
            }

            Assert.IsFalse(thrown);

        }
Exemplo n.º 8
0
        public void Incentive_Should_Throw_When_Exipired() {
            Order order = GetTestOrder();

            //DateTime.Now will always be expired
            Incentive i = new Incentive("XYZ", new PercentOffOrderCoupon(10), DateTime.Now);

            bool thrown = false;
            try {
                i.ValidateUse(order);
            }
            catch (Exception x) {
                thrown = true;
                Assert.AreEqual("This coupon is Expired", x.Message);
            }

            Assert.IsTrue(thrown);

        }
Exemplo n.º 9
0
        public void Incentive_Should_Throw_When_MinPurchase_IsMore_Than_OrderSubTotal() {
            Order order = GetTestOrder();

            Incentive i = new Incentive("XYZ", new PercentOffOrderCoupon(10), DateTime.Now.AddDays(1));
            
            //order subtotal is 40
            i.MininumPurchase = 100;
            
            bool thrown = false;
            try {
                i.ValidateUse(order);
            }
            catch (Exception x) {
                thrown = true;
                Assert.AreEqual("There is a minimum of " + i.MininumPurchase.ToString("C") + " required", x.Message);
            }

            Assert.IsTrue(thrown);

        }