Exemplo n.º 1
0
        public async Task GetRandomGuid_Returns_NOTFOUND()
        {
            using (var client = new TestClientProvider().Client)
            {
                Guid guid     = Guid.NewGuid();
                var  response = await client.GetAsync($"/api/orders/{guid}");

                Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
            }
        }
Exemplo n.º 2
0
        public async Task GetOrderById_Returns_Order()
        {
            using (var client = new TestClientProvider().Client)
            {
                var orderResponse = await client.GetAsync($"/api/orders/{_fixture.order.Id}");

                using (var responseStream = await orderResponse.Content.ReadAsStreamAsync())
                {
                    var order = await System.Text.Json.JsonSerializer.DeserializeAsync <Order>(responseStream,
                                                                                               new JsonSerializerOptions()
                    {
                        PropertyNameCaseInsensitive = true
                    });

                    Assert.Equal(_fixture.order.Id, order.Id);
                }
            }
        }
Exemplo n.º 3
0
        public async Task GetAll_Returns_orderitems()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.GetAsync("/api/orders");

                var orderResponse = await response.Content.ReadAsStringAsync();

                var orders = JsonConvert.DeserializeObject <IEnumerable <Order> >(orderResponse);

                foreach (var order in orders)
                {
                    foreach (var orderItem in order.OrderItems)
                    {
                        Assert.NotNull(orderItem);
                    }
                }
            }
        }