public async Task <IHttpActionResult> GetAsync(Guid id) { if (!await _itemCacher.ItemExists(id)) { return(NotFound()); } var item = await _itemCacher.GetItem(id); return(Ok(item)); }
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()); }
public async Task ItemExists_ExistingItemId_TrueReturned() { var result = await _itemCacher.ItemExists(FakeItem.Id); Assert.That(result, Is.EqualTo(true)); }