public void GetStoryCached_ValidId_ReturnsStory() { var story = new Item { Id = 1, Title = "Test", Type = ItemType.Story, Url = "https://www.google.com" }; _ = _storyCacheService.AddStoryToCache(story); var result = _storyCacheService.GetStoryCached(story.Id); Assert.That(result, Is.EqualTo(story)); }
public async Task <Item> GetItem(int id) { var story = _cache.GetStoryCached(id); if (story != null) { return(story); } try { story = await _storyService.GetItem(id).ConfigureAwait(false); if (story == null) { return(null); } _cache.AddStoryToCache(story); return(story); } catch { return(null); } }