public async void TestSubscriptionsCreateRequest()
        {
            Product product2 = await ProductsCreateTest.CreateProductIfNotExists(ProductsCreateTest.ProductId2);

            var planResponse = await PlansCreateTest.CreatePlan(product2.Id, freeTrial : true, qtySupported : true);

            Assert.Equal(201, (int)planResponse.StatusCode);
            Assert.NotNull(planResponse.Result <Plan>());
            Plan createdPlan = planResponse.Result <Plan>();

            var response = await CreateSubscription(createdPlan.Id);

            Assert.Equal(201, (int)response.StatusCode);
            Assert.NotNull(response.Result <Subscription>());

            Subscription createdSubscription = response.Result <Subscription>();

            Assert.NotNull(createdSubscription.Id);

            Assert.NotNull(createdSubscription.CreateTime);

            Assert.NotNull(createdSubscription.Links);
            bool foundApproveURL = false;

            foreach (var linkDescription in createdSubscription.Links)
            {
                if ("edit".Equals(linkDescription.Rel))
                {
                    foundApproveURL = true;
                    Assert.NotNull(linkDescription.Href);
                    Assert.Equal("PATCH", linkDescription.Method);
                    Console.WriteLine(linkDescription.Href);
                }
            }

            Console.WriteLine(createdSubscription.Id);
            Assert.True(foundApproveURL);

            // - Get Subscription
            SubscriptionsGetRequest getRequest = new SubscriptionsGetRequest(createdSubscription.Id, fields: "last_failed_payment,plan");
            var getResponse = await TestHarness.client().Execute(getRequest);

            Assert.Equal(200, (int)getResponse.StatusCode);
            Subscription getSubscription = getResponse.Result <Subscription>();

            Assert.NotNull(getSubscription);
            Assert.NotNull(getSubscription.Plan);
        }
Пример #2
0
        public async void TestPlansGetRequest()
        {
            var createProductResponse = await ProductsCreateTest.CreateProduct();

            Product product1      = createProductResponse.Result <Product>();
            var     plan1Response = await PlansCreateTest.CreatePlan(product1.Id, false, false);

            Plan plan1         = plan1Response.Result <Plan>();
            var  plan2Response = await PlansCreateTest.CreatePlan(product1.Id, true, true);

            Plan plan2 = plan2Response.Result <Plan>();

            List <string> planIds = new List <string>()
            {
                plan1.Id, plan2.Id
            };

            Console.WriteLine(planIds[0] + " " + planIds[1]);

            PlansGetRequest request = new PlansGetRequest(product1.Id);

            var response = await TestHarness.client().Execute(request);

            Assert.Equal(200, (int)response.StatusCode);

            PlanCollection retrievedPlanCollection = response.Result <PlanCollection>();

            Assert.NotNull(retrievedPlanCollection);
            Assert.NotEmpty(retrievedPlanCollection.Plans);
            Assert.Equal(2, retrievedPlanCollection.Plans.Count);
            Assert.NotNull(retrievedPlanCollection.Plans.FirstOrDefault(f => f.Id == plan1.Id));
            Assert.NotNull(retrievedPlanCollection.Plans.FirstOrDefault(f => f.Id == plan2.Id));


            Assert.NotNull(retrievedPlanCollection.Links);
        }