/// <summary> /// Default constructor with 10 minute InMemoryCaching /// </summary> public ArtistController() { int cacheTimeMinutes = 10; InMemoryCache cache = new InMemoryCache(cacheTimeMinutes); _client = new MusicGenieClient(cache); }
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"); }
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); }
/// <summary> /// Custom cache constructor for dependency injection /// </summary> /// <param name="cache"></param> public ArtistController(MusicGenieClient client) { _client = client; }