public void GetById_ShouldReturnStatusOk()
        {
            var ingredientRequest = new RestRequest("Ingredient", Method.POST);
            var ingredient = new IngredientModel
            {
                Name = "ingredient1",
                Price = 123
            };
            ingredientRequest.AddJsonBody(ingredient);

            var ingredientResponse = Client.Execute(ingredientRequest);

            Assert.That(ingredientResponse, Is.Not.Null);
            Assert.That(ingredientResponse.StatusCode, Is.EqualTo(HttpStatusCode.Created));
            var returnedIngredientModel = _jsonDeserializer.Deserialize<IngredientModel>(ingredientResponse);

            var pizzaRequest = new RestRequest("Pizza", Method.POST);
            var pizza = new PizzaModel
            {
                Name = "pizza1",
                Price = 123,
                Toppings = new List<IngredientModel> { returnedIngredientModel }
            };
            pizzaRequest.AddJsonBody(pizza);

            var pizzaResponse = Client.Execute(pizzaRequest);

            Assert.That(pizzaResponse, Is.Not.Null);
            Assert.That(pizzaResponse.StatusCode, Is.EqualTo(HttpStatusCode.Created));
            var returnedPizzaModel = _jsonDeserializer.Deserialize<PizzaModel>(pizzaResponse);

            var request = new RestRequest(ResourceName, Method.POST);
            var order = new OrderModel
            {
                CreationDate = DateTimeOffset.Now,
                Price = 123,
                Address = "address",
                Pizzas = new List<PizzaModel> { returnedPizzaModel }
            };
            request.AddJsonBody(order);

            var response = Client.Execute(request);

            Assert.That(response, Is.Not.Null);
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Created));

            var orderModel = _jsonDeserializer.Deserialize<OrderModel>(response);

            var getRequest = new RestRequest(ResourceNameWithParameter, Method.GET);
            getRequest.AddUrlSegment("id", orderModel.Id.ToString());
            var getResponse = Client.Execute(getRequest);

            Assert.That(getResponse, Is.Not.Null);
            Assert.That(getResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
            var returnedOrderModel = _jsonDeserializer.Deserialize<IngredientModel>(getResponse);
            Assert.That(returnedOrderModel, Is.Not.Null);
            Assert.That(returnedOrderModel.Id, Is.EqualTo(orderModel.Id));
        }
        public IHttpActionResult CreatePizza(PizzaModel pizzaModel)
        {
            var pizza = Mapper.Map<Pizza>(pizzaModel);

            var pizzaDb = _pizzaService.Add(pizza);

            return CreatedAtRoute("GetPizzaById",
                new { id = pizzaDb.Id },
                Mapper.Map<PizzaModel>(pizzaDb));
        }
        public void Post_ShouldReturnStatusCodeCreated()
        {
            var ingredientRequest = new RestRequest("Ingredient", Method.POST);
            var ingredient = new IngredientModel
            {
                Name = "ingredient1",
                Price = 123
            };
            ingredientRequest.AddJsonBody(ingredient);

            var ingredientResponse = Client.Execute(ingredientRequest);

            Assert.That(ingredientResponse, Is.Not.Null);
            Assert.That(ingredientResponse.StatusCode, Is.EqualTo(HttpStatusCode.Created));
            var returnedIngredientModel = _jsonDeserializer.Deserialize<IngredientModel>(ingredientResponse);

            var pizzaRequest = new RestRequest("Pizza", Method.POST);
            var pizza = new PizzaModel
            {
                Name = "pizza1",
                Price = 123,
                Toppings = new List<IngredientModel> { returnedIngredientModel }
            };
            pizzaRequest.AddJsonBody(pizza);

            var pizzaResponse = Client.Execute(pizzaRequest);

            Assert.That(pizzaResponse, Is.Not.Null);
            Assert.That(pizzaResponse.StatusCode, Is.EqualTo(HttpStatusCode.Created));
            var returnedPizzaModel = _jsonDeserializer.Deserialize<PizzaModel>(pizzaResponse);

            var request = new RestRequest(ResourceName, Method.POST);
            var order = new OrderModel
            {
                CreationDate = DateTimeOffset.Now,
                Price = 123,
                Address = "address",
                Pizzas = new List<PizzaModel> { returnedPizzaModel}
            };
            request.AddJsonBody(order);

            var response = Client.Execute(request);

            Assert.That(response, Is.Not.Null);
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Created));
        }