Exemplo n.º 1
0
        public async Task PlaceOrder_ReturnsOK()
        {
            Guid orderId = Guid.NewGuid();

            var order = new OrderDto()
            {
                Date         = DateTime.Now,
                Id           = Guid.NewGuid(),
                TotalPrice   = 123,
                UserId       = "c30936a4-80b0-4209-84e2-98e9336e9c80",
                OrderRowsDto = new List <OrderRowDto>()
            };

            using (var client = new TestClientProvider().Client)
            {
                var request = new HttpRequestMessage(HttpMethod.Post, $"/api/order/placeorder");

                var itemJson = JsonConvert.SerializeObject(order);
                request.Content = new StringContent(itemJson, Encoding.UTF8, "application/json");
                var response = await client.SendAsync(request);

                Assert.Equal(HttpStatusCode.OK, response.StatusCode);


                // Delete order


                orderId = order.Id;
                var responseDeleteItem = await client.DeleteAsync($"/api/order/delete?id={orderId}");

                responseDeleteItem.EnsureSuccessStatusCode();
            }
        }
Exemplo n.º 2
0
        public async void Dispose()
        {
            using (var client = new TestClientProvider().Client)
            {
                var deleteResponse = await client.DeleteAsync($"/api/order/delete?id={order.Id}");

                using (var responseStream = await deleteResponse.Content.ReadAsStreamAsync())
                {
                    var deleteId = await JsonSerializer.DeserializeAsync <Guid>(responseStream,
                                                                                new JsonSerializerOptions()
                    {
                        PropertyNameCaseInsensitive = true
                    });
                }
            }
        }