Missed caching API updates

This commit is contained in:
John Luo 2017-07-07 22:06:20 -07:00
parent 9ebece44e0
commit 492f820cf7
1 changed files with 6 additions and 5 deletions

View File

@ -21,6 +21,7 @@ using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Internal; using Microsoft.Extensions.Internal;
using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.WebEncoders.Testing; using Microsoft.Extensions.WebEncoders.Testing;
using Moq; using Moq;
using Xunit; using Xunit;
@ -355,7 +356,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
var clock = new Mock<ISystemClock>(); var clock = new Mock<ISystemClock>();
clock.SetupGet(p => p.UtcNow) clock.SetupGet(p => p.UtcNow)
.Returns(() => currentTime); .Returns(() => currentTime);
var storage = GetStorage(new MemoryCacheOptions { Clock = clock.Object }); var storage = GetStorage(Options.Create(new MemoryDistributedCacheOptions { Clock = clock.Object }));
var service = new DistributedCacheTagHelperService( var service = new DistributedCacheTagHelperService(
storage, storage,
Mock.Of<IDistributedCacheTagHelperFormatter>(), Mock.Of<IDistributedCacheTagHelperFormatter>(),
@ -417,7 +418,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
var clock = new Mock<ISystemClock>(); var clock = new Mock<ISystemClock>();
clock.SetupGet(p => p.UtcNow) clock.SetupGet(p => p.UtcNow)
.Returns(() => currentTime); .Returns(() => currentTime);
var storage = GetStorage(new MemoryCacheOptions { Clock = clock.Object }); var storage = GetStorage(Options.Create(new MemoryDistributedCacheOptions { Clock = clock.Object }));
var service = new DistributedCacheTagHelperService( var service = new DistributedCacheTagHelperService(
storage, storage,
Mock.Of<IDistributedCacheTagHelperFormatter>(), Mock.Of<IDistributedCacheTagHelperFormatter>(),
@ -479,7 +480,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
var clock = new Mock<ISystemClock>(); var clock = new Mock<ISystemClock>();
clock.SetupGet(p => p.UtcNow) clock.SetupGet(p => p.UtcNow)
.Returns(() => currentTime); .Returns(() => currentTime);
var storage = GetStorage(new MemoryCacheOptions { Clock = clock.Object }); var storage = GetStorage(Options.Create(new MemoryDistributedCacheOptions { Clock = clock.Object }));
var service = new DistributedCacheTagHelperService( var service = new DistributedCacheTagHelperService(
storage, storage,
Mock.Of<IDistributedCacheTagHelperFormatter>(), Mock.Of<IDistributedCacheTagHelperFormatter>(),
@ -775,9 +776,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
}); });
} }
private static IDistributedCacheTagHelperStorage GetStorage(MemoryCacheOptions options = null) private static IDistributedCacheTagHelperStorage GetStorage(IOptions<MemoryDistributedCacheOptions> options = null)
{ {
return new DistributedCacheTagHelperStorage(new MemoryDistributedCache(new MemoryCache(options ?? new MemoryCacheOptions()))); return new DistributedCacheTagHelperStorage(new MemoryDistributedCache(options ?? Options.Create(new MemoryDistributedCacheOptions())));
} }
private static IDistributedCacheTagHelperFormatter GetFormatter() private static IDistributedCacheTagHelperFormatter GetFormatter()