public void ShouldThrowMollieApiExceptionWhenInvalidParametersAreGiven() { // If: we create a payment request with invalid parameters PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = null, RedirectUrl = null }; // Then: Send the payment request to the Mollie Api, this should throw a mollie api exception AggregateException aggregateException = Assert.ThrowsException <AggregateException>(() => PaymentClient.CreatePaymentAsync(paymentRequest).Wait()); MollieApiException mollieApiException = aggregateException.InnerExceptions.FirstOrDefault(x => x.GetType() == typeof(MollieApiException)) as MollieApiException; Assert.IsNotNull(mollieApiException); Assert.IsNotNull(mollieApiException.Details); Assert.IsTrue(!string.IsNullOrEmpty(mollieApiException.Details.Detail)); }
public async Task CanDeleteCustomer() { // If: We retrieve the customer list ListResponse <CustomerResponse> response = await CustomerClient.GetCustomerListAsync(); if (response.Items.Count == 0) { Assert.Inconclusive("No customers found. Unable to test deleting customers"); } // When: We delete one of the customers in the list string customerIdToDelete = response.Items.First().Id; await CustomerClient.DeleteCustomerAsync(customerIdToDelete); // Then: Make sure its deleted AggregateException aggregateException = Assert.ThrowsException <AggregateException>(() => CustomerClient.GetCustomerAsync(customerIdToDelete).Wait()); MollieApiException mollieApiException = aggregateException.InnerExceptions.FirstOrDefault(x => x.GetType() == typeof(MollieApiException)) as MollieApiException; Assert.AreEqual((int)HttpStatusCode.Gone, mollieApiException.Details.Status); }