示例#1
0
        public IHttpActionResult GetItemById([FromUri] int id)
        {
            var action = new Func <IHttpActionResult>(() =>
            {
                var result = _productDataServices.GetItemById(id);
                return(result != null ? (IHttpActionResult)Ok(result) : new NotFoundResult(this));
            });

            return(ErrorHandlerWrapper(action));
        }
        public void Get_item_by_id_should_return_correct_item(int id)
        {
            var expectedItem = MockItems.FirstOrDefault(q => q.Id == id);
            var result       = _applicationServices.GetItemById(id);

            Assert.IsNotNull(result);
            Assert.IsNotNull(expectedItem);
            Assert.That(expectedItem.Id == result.Id);
            Assert.That(expectedItem.Name == result.Name);
            Assert.That(expectedItem.Cost == result.Cost);
        }