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

            var item = await _itemCacher.GetItem(id);

            return(Ok(item));
        }
Exemplo n.º 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());
        }
Exemplo n.º 3
0
        public async Task ItemExists_ExistingItemId_TrueReturned()
        {
            var result = await _itemCacher.ItemExists(FakeItem.Id);

            Assert.That(result, Is.EqualTo(true));
        }