public async Task ClientRequest_WithMaxAge_AddsToCache() { // arrange var state = new TestState(); var expectedResponse = state.AddHttpRequest(1); expectedResponse.Headers.CacheControl = new CacheControlHeaderValue { MaxAge = TimeSpan.FromDays(1) }; // act var response = await state.ExecuteRequest(); // assert Predicate <Tuple <string, CachingHttpClient.CachedValues> > assert = AssertResult; state.Dependencies .Verify(x => x.Cache.Put(Match.Create(assert)), Times.Once); bool AssertResult(Tuple <string, CachingHttpClient.CachedValues> input) { Assert.AreEqual("G$:$:http://www.com/", input.Item1); CustomAssert.AssertCachedResponse(1, input.Item2.HttpResponse); CustomAssert.AssertDateAlmost( DateTime.UtcNow.AddDays(1), ((Headers.CacheSettings.ExpirySettings.HardUtc)input.Item2.CacheSettings.ExpirySettings).Item); return(true); } }