public void Resolve_twice_with_no_CompressionType_does_not_cache_compressed_result() { var xmlResult = ContentCacheManager.Resolve( () => model, MimeTypes.Xml, null, cacheClient, CacheKey, null); Assert.That(xmlResult, Is.EqualTo(xmlModel)); xmlResult = ContentCacheManager.Resolve( () => model, MimeTypes.Xml, null, cacheClient, CacheKey, null); Assert.That(xmlResult, Is.EqualTo(xmlModel)); var cachedResult = cacheClient.Get <ModelWithIdAndName>(CacheKey); ModelWithIdAndName.AssertIsEqual(model, cachedResult); var serializedCacheKey = ContentCacheManager.GetSerializedCacheKey(CacheKey, MimeTypes.Xml); var serializedCachedResult = cacheClient.Get <string>(serializedCacheKey); Assert.That(serializedCachedResult, Is.EqualTo(xmlModel)); AssertNoCompressedResults(cacheClient, serializedCacheKey); }
private static void AssertNoSerializedResults( ICacheClient cacheClient, string cacheKey) { foreach (var mimeType in ContentCacheManager.AllCachedMimeTypes) { var serializedCacheKey = ContentCacheManager.GetSerializedCacheKey( cacheKey, mimeType); var serializedResult = cacheClient.Get <string>(serializedCacheKey); Assert.That(serializedResult, Is.Null); } }
public void Can_cache_null_result() { var xmlResult = ContentCacheManager.Resolve <ModelWithIdAndName>( () => null, serializationContext, cacheClient, CacheKey, null); Assert.That(xmlResult, Is.Null); var cachedResult = cacheClient.Get <ModelWithIdAndName>(CacheKey); Assert.That(cachedResult, Is.Null); var serializedCacheKey = ContentCacheManager.GetSerializedCacheKey(CacheKey, MimeTypes.Xml); var serializedCachedResult = cacheClient.Get <string>(serializedCacheKey); Assert.That(serializedCachedResult, Is.Null); AssertNoCompressedResults(cacheClient, serializedCacheKey); }