public async Task <IHttpActionResult> GetAsync(Guid id)
        {
            if (!await _itemCacher.ItemExists(id))
            {
                return(NotFound());
            }

            var item = await _itemCacher.GetItem(id);

            return(Ok(item));
        }
Example #2
0
        public async Task GetItem_ExistingId_ItemReturned()
        {
            _itemCacher.ItemExists(FakeItem.Id).Returns(true);
            _itemCacher.GetItem(FakeItem.Id).Returns(FakeItem);

            _itemCacher.ItemExists(Guid.Empty).Returns(false);

            var response = await _controller.ResolveAction(controller => controller.GetAsync(FakeItem.Id)).BeItReducedResponse <Item>();

            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK))
            .AndThat(response.Content, Is.EqualTo(FakeItem).UsingItemModelComparer());
        }
Example #3
0
        public async Task GetItem_ExistingItemId_ItemReturned()
        {
            var receivedItem = await _itemCacher.GetItem(FakeItem.Id);

            Assert.That(receivedItem, Is.EqualTo(FakeItem));
        }