Example #1
0
        /// <summary>
        /// Default constructor with 10 minute InMemoryCaching
        /// </summary>
        public ArtistController()
        {
            int           cacheTimeMinutes = 10;
            InMemoryCache cache            = new InMemoryCache(cacheTimeMinutes);

            _client = new MusicGenieClient(cache);
        }
Example #2
0
        public async Task TestFailedRequest_ShouldThrowHttpRequestException()
        {
            var memory = new InMemoryCache(1, new MemoryCache("unit-test-cache3"));
            MusicGenieClient client = new MusicGenieClient(memory);
            var result = "";

            result = await client.SendRequestAsync("https://thisurlisgoingtofail.org/fortestingpurposes");
        }
Example #3
0
        public async Task GetRequestFromFromCache_ShouldReturnNonEmptyString()
        {
            string uri             = "https://fake.url.irrelevant.org/shouldstillwork";
            string expectedSummary = await GetGenericSummary();

            var memory = new InMemoryCache(1, new MemoryCache("unit-test-cache"));
            await memory.GetOrSet(uri, () => GetGenericSummary());

            var client = new MusicGenieClient(memory);
            var result = await client.SendRequestAsyncCached(uri);

            Assert.AreEqual(expectedSummary, result);
        }
Example #4
0
 /// <summary>
 /// Custom cache constructor for dependency injection
 /// </summary>
 /// <param name="cache"></param>
 public ArtistController(MusicGenieClient client)
 {
     _client = client;
 }