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

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

            // When
            if (subscriptions.Count > 0)
            {
                string subscriptionId             = subscriptions.Items.First().Id;
                SubscriptionUpdateRequest request = new SubscriptionUpdateRequest()
                {
                    Description = $"Updated subscription {Guid.NewGuid()}"
                };
                SubscriptionResponse response = await SubscriptionClient.UpdateSubscriptionAsync(customerId, subscriptionId, request);

                // Then
                Assert.AreEqual(request.Description, response.Description);
            }
            else
            {
                Assert.Inconclusive("No subscriptions found that could be cancelled");
            }
        }
Beispiel #2
0
        public async Task CanUpdateSubscription()
        {
            // Given
            var customerId = await GetFirstCustomerWithValidMandate();

            var subscriptions = await SubscriptionClient.GetSubscriptionListAsync(customerId);

            // When
            if (subscriptions.Count > 0)
            {
                var subscriptionId = subscriptions.Items.First().Id;
                var request        = new SubscriptionUpdateRequest()
                {
                    Description = $"Updated subscription {Guid.NewGuid()}"
                };
                var response = await SubscriptionClient.UpdateSubscriptionAsync(customerId, subscriptionId, request);

                // Then
                Assert.Equal(request.Description, response.Description);
            }
            else
            {
                Assert.Empty(subscriptions.Items); //No subscriptions found that could be cancelled
            }
        }
        public async Task CanRetrieveSubscriptionList()
        {
            // Given
            string customerId = await GetFirstCustomerWithValidMandate();

            // When: Retrieve subscription list with default settings
            ListResponse <SubscriptionResponse> response = await SubscriptionClient.GetSubscriptionListAsync(customerId);

            // Then
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Items);
        }
        public async Task ListSubscriptionsNeverReturnsMoreCustomersThenTheNumberOfRequestedSubscriptions()
        {
            // Given: Number of customers requested is 5
            string customerId = await GetFirstCustomerWithValidMandate();

            int numberOfSubscriptions = 5;

            // When: Retrieve 5 subscriptions
            ListResponse <SubscriptionResponse> response = await SubscriptionClient.GetSubscriptionListAsync(customerId, null, numberOfSubscriptions);

            // Then
            Assert.IsTrue(response.Items.Count <= numberOfSubscriptions);
        }
        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");
            }
        }
Beispiel #6
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
            }
        }