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 CreateOrder(OrderModel orderModel)
        {
            var order = Mapper.Map<Order>(orderModel);

            var orderDb = _orderService.Add(order);

            return CreatedAtRoute("GetOrderById",
                new { id = orderDb.Id },
                Mapper.Map<OrderModel>(orderDb));
        }
        public async void PutOrder_ShouldReturnStatusCodeOk_WhenOrderWasUpdate()
        {
                var order = new Order
            {
                Id = 1,
                Address = "Poznań",
                Price = 10.2M,
                Status = "Created"
            };

            var orderModel = new OrderModel
            {
                Id = 1,
                Address = "Poznań",
                Price = 10.2M,
                Status = "InProgress"
            };
        
            A.CallTo(() => _orderService.Update(int.MaxValue, "InProgress")).Returns(order);

            var result = _sut.UpdateOrder(int.MaxValue, orderModel);

            var response = await result.ExecuteAsync(CancellationToken.None);
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
        }
        public IHttpActionResult UpdateOrder(int id, OrderModel orderModel)
        {
            var orderDb = _orderService.Update(id, orderModel.Status);

            return Ok(Mapper.Map<OrderModel>(orderDb));
        }
        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));
        }