public async Task CreateOrder_WithValidOrderResource_ShouldCreateOrder()
        {
            var body = new OrderResourceBuilder()
                       .WithDefaultValues()
                       .Build();

            var client      = GetClient();
            var getResponse = await client.GetAsync("api/orders");

            getResponse.StatusCode.Should().Be(HttpStatusCode.OK);

            var ordersContent = await getResponse.Content.ReadAsStringAsync();

            var orders = Newtonsoft.Json.JsonConvert.DeserializeObject <IReadOnlyCollection <OrderResource> >(ordersContent);

            orders.Count.Should().Be(2);

            var content = new StringContent(JsonSerializer.Serialize(body), Encoding.UTF8, "application/json");

            var postResponse = await client.PostAsync("api/orders/create", content);

            postResponse.StatusCode.Should().Be(HttpStatusCode.OK);

            var createdOrderResponse = await postResponse.Content.ReadAsStringAsync();

            var createdOrder = Newtonsoft.Json.JsonConvert.DeserializeObject <OrderResource>(createdOrderResponse);

            createdOrder.CreatedById.Should().Be(body.CreatedById);
            createdOrder.CreatedByUsername.Should().Be(body.CreatedByUsername);
            createdOrder.CreatedOn.Should().BeAfter(DateTime.MinValue);
            createdOrder.LastModifiedById.Should().Be(body.CreatedById);
            createdOrder.LastModifiedOn.Should().BeAfter(DateTime.MinValue);
            createdOrder.TotalPrice.Should().Be(body.TotalPrice);
            createdOrder.OrderItems.Count.Should().Be(body.OrderItems.Count);
            createdOrder.Id.Should().BeGreaterThan(0);

            var orderItemFromCreatedOrder = createdOrder.OrderItems.First();
            var orderItemFromBody         = body.OrderItems.First();

            orderItemFromCreatedOrder.CreatedById.Should().Be(orderItemFromBody.CreatedById);
            orderItemFromCreatedOrder.Ingredients.Should().Be(orderItemFromBody.Ingredients);
            orderItemFromCreatedOrder.PastelId.Should().Be(orderItemFromBody.PastelId);
            orderItemFromCreatedOrder.Price.Should().Be(orderItemFromBody.Price);
            orderItemFromCreatedOrder.Quantity.Should().Be(orderItemFromBody.Quantity);
            orderItemFromCreatedOrder.Name.Should().Be(orderItemFromBody.Name);
            orderItemFromCreatedOrder.OrderId.Should().Be(createdOrder.Id);
            orderItemFromCreatedOrder.Id.Should().BeGreaterThan(0);

            getResponse = await client.GetAsync("api/orders");

            getResponse.StatusCode.Should().Be(HttpStatusCode.OK);

            ordersContent = await getResponse.Content.ReadAsStringAsync();

            orders = Newtonsoft.Json.JsonConvert.DeserializeObject <IReadOnlyCollection <OrderResource> >(ordersContent);

            orders.Count.Should().Be(3);
        }
        public async Task CreateOrder_WithEmptyOrderItemsList_ResponseStatusCodeShouldBeBadRequest()
        {
            var body = new OrderResourceBuilder()
                       .WithDefaultValues()
                       .WithOrderItems(new List <OrderItemResource>())
                       .Build();

            var content = new StringContent(JsonSerializer.Serialize(body), Encoding.UTF8, "application/json");

            var client       = GetClient();
            var postResponse = await client.PostAsync("api/orders/create", content);

            postResponse.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }
        public async Task CreateOrder_WithUserIdNotFound_ResponseStatusCodeShouldBeNotFound()
        {
            var body = new OrderResourceBuilder()
                       .WithDefaultValues()
                       .WithCreatedById(200)
                       .Build();

            var content = new StringContent(JsonSerializer.Serialize(body), Encoding.UTF8, "application/json");

            var client       = GetClient();
            var postResponse = await client.PostAsync("api/orders/create", content);

            postResponse.StatusCode.Should().Be(HttpStatusCode.NotFound);
        }
        public async Task CreateOrder_WithNegativeAndZeroQuantityInOrderItem_ResponseStatusCodeShouldBeBadRequest(int quantity)
        {
            var orderItemResource = new OrderItemResource
            {
                CreatedById = 1,
                Ingredients = "Queijo",
                Name        = "Pastel de Queijo",
                PastelId    = 1,
                Price       = 4,
                Quantity    = quantity
            };

            var body = new OrderResourceBuilder()
                       .WithDefaultValues()
                       .WithOrderItems(new[] { orderItemResource })
                       .Build();

            var content = new StringContent(JsonSerializer.Serialize(body), Encoding.UTF8, "application/json");

            var client       = GetClient();
            var postResponse = await client.PostAsync("api/orders/create", content);

            postResponse.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }