Ejemplo n.º 1
0
        public void Coupon_Create()
        {
            // Arrange
            var    productFamily = Chargify.GetProductFamilyList().Values.FirstOrDefault();
            string couponCode    = Guid.NewGuid().ToString().Replace("-", string.Empty).ToUpperInvariant().Substring(0, 8);
            var    newCoupon     = new Coupon()
            {
                AllowNegativeBalance = false,
                Code                = couponCode,
                Description         = couponCode + " description",
                DurationPeriodCount = 2,
                EndDate             = DateTime.Today.AddDays(5),
                IsRecurring         = true,
                Name                = "coupon " + couponCode,
                Percentage          = 50,
                AmountInCents       = 0
            };

            // Act
            var createdCoupon = Chargify.CreateCoupon(newCoupon, productFamily.ID);

            // Assert
            Assert.IsNotNull(createdCoupon);
            //Assert.IsInstanceOfType(createdCoupon, typeof(ICoupon));
            Assert.IsTrue(createdCoupon.AllowNegativeBalance == newCoupon.AllowNegativeBalance);
            Assert.IsTrue(createdCoupon.Name == newCoupon.Name);
            Assert.IsTrue(createdCoupon.Description == newCoupon.Description);
            Assert.IsTrue(createdCoupon.Code == newCoupon.Code);
        }