public void AddStoryToCache_NewStory_ReturnsStory()
        {
            var story = new Item
            {
                Id = 1,
                Title = "Test",
                Type = ItemType.Story,
                Url = "https://www.google.com"
            };

            var result = _storyCacheService.AddStoryToCache(story);
            Assert.That(story, Is.EqualTo(result));
        }
Example #2
0
        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);
            }
        }