public async Task Then_404_is_not_returned() { var client = new WebApplicationFactory <Startup>().CreateClient(); var response = await client.PostAsync("/Invitations/" + Guid.NewGuid(), new StringContent("")); response.StatusCode.Should().NotBe(HttpStatusCode.NotFound); }
public async Task Then_404_NotFound_Is_Not_Returned() { var client = new WebApplicationFactory <Startup>().CreateClient(); var response = await client.PostAsync("/Account/Login", new StringContent("")); response.StatusCode.Should().NotBe(HttpStatusCode.NotFound); response.StatusCode.Should().NotBe(HttpStatusCode.MethodNotAllowed); }
private async Task <HttpResponseMessage> CreateOrder() { var client = new WebApplicationFactory <Program>() .WithWebHostBuilder(builder => { builder.ConfigureServices(services => { services.AddTransient <IOrderRepository>(_ => _repository); }); }) .CreateClient(); return(await client.PostAsync("orders/create", null)); }
public async Task SortEndpointIsConfiguredAndReturnsCorrectJsonResponseForRecommended() { // Arrange var httpClient = new WebApplicationFactory <Api.Startup>().Server.CreateClient(); var requestContent = "{\"products\": [{\"name\": \"test\",\"price\": 100.0}],\"specials\": [{\"quantities\": [{\"name\": \"test\",\"quantity\": 2}],\"total\":150}],\"quantities\": [{\"name\": \"test\",\"quantity\": 2}]}"; // Act var httpResponseMessage = await httpClient.PostAsync("/trolleyTotal", new StringContent(requestContent, Encoding.UTF8, "application/json")); // Assert var readAsStringAsync = await httpResponseMessage.Content.ReadAsStringAsync(); httpResponseMessage.StatusCode.Should().Be(StatusCodes.Status200OK); readAsStringAsync.Should().Be("150"); }