public async Task Always_returns_NotFound_When_try_to_get_non_existing_PaymentDetails() { var client = new HttpClient { BaseAddress = new Uri("https://localhost:5001") }; client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var clients = Enumerable.Repeat(client, 1); var posts = clients.Select(c => { var paymentRequest = TestsUtils.BuildPaymentRequest(Guid.NewGuid(), MerchantsRepository.Amazon); var content = new StringContent(JsonConvert.SerializeObject(paymentRequest)); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(c.GetAsync("api/PaymentsDetails/f31499cc-ece3-4974-8785-1620d8c506f6")); }); foreach (var response in await Task.WhenAll(posts)) { Check.That(response.StatusCode).IsEqualTo(HttpStatusCode.NotFound); } }
public static async Task RequestPayments(int concurrentClientsCount) { const string baseUri = "https://localhost:5001"; var clients = BuildHttpClients(concurrentClientsCount, baseUri); IEnumerable <Task <PaymentDto> > posts = clients.Select(async(c, index) => { Console.WriteLine($"client {index}"); var paymentRequest = TestsUtils.BuildPaymentRequest(Guid.NewGuid(), MerchantsRepository.Amazon); var content = new StringContent(JsonConvert.SerializeObject(paymentRequest)); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = await c.PostAsync("/api/Payments", content); //Check.That(response.StatusCode).IsEqualTo(HttpStatusCode.Accepted); //Check.That(response.Headers.Location.ToString()).StartsWith($"{baseUri}/api/Payments/"); var payment = JsonConvert.DeserializeObject <PaymentDto>(await response.Content.ReadAsStringAsync()); //Check.That(payment.Status).IsEqualTo(Domain.PaymentStatus.Pending); //Check.That(payment.AcquiringBankPaymentId).IsNull(); return(payment); }); await Task.WhenAll(posts); }