예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }
예제 #4
0
        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");
        }