Example #1
0
        public async Task When_there_is_no_order_with_provided_id_Then_return_404_with_error_response()
        {
            var client = factory.CreateClientWithTestAuth();

            var response = await client.PostAsync("api/orders/123/finish", null);

            Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
            Assert.Equal("application/json; charset=utf-8",
                         response.Content.Headers.ContentType.ToString());
            var parsedResponse = await response.Parse <ProblemDetails>();

            Assert.Equal(StatusCodes.Status404NotFound, parsedResponse.Status);
            Assert.NotEmpty(parsedResponse.Title);
        }
Example #2
0
        public async Task Get_EndPointsReturnsFailureForUnauthorizedUser(string url)
        {
            var provider = TestClaimsProvider.WithUserClaims();
            var client   = _factory.CreateClientWithTestAuth(provider);

            var response = await client.GetAsync(url);

            response.EnsureSuccessStatusCode();
            Assert.Equal("text/html; charset=utf-8", response.Content.Headers.ContentType.ToString());
        }
Example #3
0
        public async Task When_create_with_non_existing_drink_Then_return_bad_request()
        {
            var client = factory.CreateClientWithTestAuth();

            var response = await client.PostContentAsync(
                "api/orders",
                new CreateOrderDetails
            {
                Drinks = new List <CreateOrderDrinksItem> {
                    new CreateOrderDrinksItem {
                        DrinkId = 777,
                        SizeId  = 1
                    }
                }
            });

            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
            Assert.Equal("application/problem+json; charset=utf-8",
                         response.Content.Headers.ContentType.ToString());
            var parsedResponse = await response.Parse <ProblemDetails>();

            Assert.Equal(StatusCodes.Status400BadRequest, parsedResponse.Status);
            Assert.NotEmpty(parsedResponse.Title);
        }