public async Task CanCancelSubscription()
        {
            // Given
            string customerId = await GetFirstCustomerWithValidMandate();

            ListResponse <SubscriptionResponse> subscriptions = await SubscriptionClient.GetSubscriptionListAsync(customerId);

            // When
            if (subscriptions.Count > 0)
            {
                string subscriptionId = subscriptions.Items.First().Id;
                await SubscriptionClient.CancelSubscriptionAsync(customerId, subscriptionId);

                SubscriptionResponse cancelledSubscription = await SubscriptionClient.GetSubscriptionAsync(customerId, subscriptionId);

                // Then
                Assert.AreEqual(cancelledSubscription.Status, SubscriptionStatus.Canceled);
            }
            else
            {
                Assert.Inconclusive("No subscriptions found that could be cancelled");
            }
        }
Example #2
0
        public async Task CanCancelSubscription()
        {
            // Given
            var customerId = await GetFirstCustomerWithValidMandate();

            var subscriptions = await SubscriptionClient.GetSubscriptionListAsync(customerId);

            // When
            if (subscriptions.Count > 0)
            {
                var subscriptionId = subscriptions.Items.First().Id;
                await SubscriptionClient.CancelSubscriptionAsync(customerId, subscriptionId);

                var cancelledSubscription = await SubscriptionClient.GetSubscriptionAsync(customerId, subscriptionId);

                // Then
                Assert.Equal(SubscriptionStatus.Canceled, cancelledSubscription.Status);
            }
            else
            {
                Assert.Empty(subscriptions.Items); //No subscriptions found that could be cancelled
            }
        }