public void CreateCouponPercent()
        {
            string s = Factories.GetMockCouponCode();
            Coupon c = new Coupon(s, Factories.GetMockCouponName(), 10);
            c.Create();

            Assert.IsNotNull(c.CreatedAt);

            c = Coupon.Get(s);
            Assert.IsNotNull(s);
            Assert.AreEqual(c.DiscountPercent.Value, 10);
            Assert.AreEqual(c.DiscountType, Coupon.CouponDiscountType.percent);
        }
        public void DeactivateCoupon()
        {
            string s = Factories.GetMockCouponCode();
            Coupon c = new Coupon(s, Factories.GetMockCouponName(), new Dictionary<string, int>());
            c.DiscountInCents.Add("USD", 100);
            c.DiscountInCents.Add("EUR", 50);

            c.Create();

            Assert.IsNotNull(c.CreatedAt);

            c.Deactivate();

            c = Coupon.Get(s);
            Assert.IsNotNull(s);
            Assert.AreEqual(c.State, Coupon.CouponState.inactive);
        }
        public void CreateCouponDollars()
        {
            string s = Factories.GetMockCouponCode();
            Coupon c = new Coupon(s, Factories.GetMockCouponName(), new Dictionary<string,int>());
            c.DiscountInCents.Add("USD", 100);
            c.DiscountInCents.Add("EUR", 50);

            c.Create();

            Assert.IsNotNull(c.CreatedAt);

            c = Coupon.Get(s);
            Assert.IsNotNull(s);
            Assert.AreEqual(c.DiscountInCents["USD"], 100);
            Assert.AreEqual(c.DiscountInCents["EUR"], 50);
            Assert.AreEqual(c.DiscountType, Coupon.CouponDiscountType.dollars);
        }
        public void RedeemCoupon()
        {
            string s = Factories.GetMockCouponCode();
            Coupon c = new Coupon(s, Factories.GetMockCouponName(), 10);
            c.Create();

            string act = Factories.GetMockAccountName();
            Account acct = new Account(act);
            acct.Create();
            Assert.IsNotNull(acct.CreatedAt);

            CouponRedemption cr = acct.RedeemCoupon(s, "USD");
            Thread.Sleep(2000);
            Assert.IsNotNull(cr);
            Assert.AreEqual(cr.Currency, "USD");
            Assert.AreEqual(cr.AccountCode, act);
        }
        public void LookupRedemption()
        {
            string s = Factories.GetMockCouponCode();
            Coupon c = new Coupon(s, Factories.GetMockCouponName(), 10);
            c.Create();

            string act = Factories.GetMockAccountName();
            Account acct = new Account(act);
            acct.Create();
            Assert.IsNotNull(acct.CreatedAt);

            CouponRedemption cr = acct.RedeemCoupon(s, "USD");

            Assert.IsNotNull(cr);

            cr = acct.GetActiveCoupon();
            Assert.AreEqual(cr.CouponCode, s);
            Assert.AreEqual(cr.AccountCode, act);
        }
        public void LookupCouponInvoice()
        {
            string s = Factories.GetMockCouponCode();
            Dictionary<string, int> discounts = new Dictionary<string,int>();
            discounts.Add("USD",1000);
            Coupon c = new Coupon(s, Factories.GetMockCouponName(), discounts);
            c.Create();

            string act = Factories.GetMockAccountName();
            Account acct = new Account(s, "John", "Doe", "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 2);
            acct.Create();

            CouponRedemption cr = acct.RedeemCoupon(s, "USD");

            Transaction t = new Transaction(acct, 5000, "USD");
            t.Create();

            CouponRedemption cr2 = Invoice.Get(t.Invoice.Value).GetCoupon();

            Assert.AreEqual(cr, cr2);
        }
        public void ListCoupons()
        {
            string s = Factories.GetMockCouponCode();
            Coupon c = new Coupon(s, Factories.GetMockCouponName(), 1);
            c.Create();
            s = Factories.GetMockCouponCode();
            c = new Coupon(s, Factories.GetMockCouponName(), 2);
            c.Create();

            CouponList list = CouponList.List();
            Assert.IsTrue(list.Count > 1);
        }
        public void ListCouponsRedeemable()
        {
            string s = Factories.GetMockCouponCode();
            Coupon c = new Coupon(s, Factories.GetMockCouponName(), 1);
            c.Create();
            c.Deactivate();
            Thread.Sleep(1000);
            s = Factories.GetMockCouponCode();
            c = new Coupon(s, Factories.GetMockCouponName(), 2);
            c.Create();

            CouponList list = CouponList.List(Coupon.CouponState.redeemable);
            Assert.IsTrue(list.Count > 1);
        }
        public void ListCouponsMaxedOut()
        {
            string s = Factories.GetMockCouponCode();
            Coupon c = new Coupon(s, Factories.GetMockCouponName(), 1);
            c.MaxRedemptions = 1;
            c.Create();

            Account t = new Account(Factories.GetMockAccountName("Coupon Redemption Max"));
            t.Create();
            t.RedeemCoupon(s, "USD");

            CouponList list = CouponList.List();
            Assert.IsTrue(list.Count > 1);
        }