示例#1
0
        public void Subscription_Create_WithCouponAfterSignup()
        {
            // Arrange
            var          product        = Chargify.GetProductList().Values.FirstOrDefault();
            var          newCustomer    = new CustomerAttributes("Scott", "Pilgrim", "*****@*****.**", "Chargify", Guid.NewGuid().ToString());
            var          newPaymentInfo = GetTestPaymentMethod(newCustomer);
            const string couponCode     = "68C8FDBA";

            // Act
            var createdSubscription = Chargify.CreateSubscription(product.Handle, newCustomer, newPaymentInfo);

            // Assert
            Assert.IsNotNull(createdSubscription);
            Assert.IsInstanceOfType(createdSubscription, typeof(Subscription));
            Assert.IsTrue(createdSubscription.CouponCode == string.Empty);

            // Act Again
            var updatedSubscription = Chargify.AddCoupon(createdSubscription.SubscriptionID, couponCode);

            // Assert Again
            Assert.IsNotNull(updatedSubscription);
            Assert.IsInstanceOfType(updatedSubscription, typeof(ISubscription));
            Assert.IsTrue(updatedSubscription.CouponCode == couponCode);
        }