protected override IConfigurationSource CreateConfigurationSource() { var innerSource = new Mock <IConfigurationSource>(); innerSource.Setup(x => x.GetAppSettingAsync <TValue>(It.IsAny <string>(), It.IsAny <CancellationToken>())) .ReturnsAsync(ConfigurationSourceResult <TValue> .FailedResult()); var source = new CachingConfigurationSourceDecorator(innerSource.Object, new CacheKeyCreator(Guid.NewGuid().ToString()), MemoryCache.Default, () => new CacheItemPolicy()); return(source); }
protected override IConfigurationSource GivenConfigurationSourceWithExistingRKey(string key, TValue expectedValue) { var innerSource = new Mock <IConfigurationSource>(); var cancellationToken = new CancellationToken(); innerSource.Setup(x => x.GetAppSettingAsync <TValue>(key, cancellationToken)) .ReturnsAsync(ConfigurationSourceResult <TValue> .SuccessResult(expectedValue)); var source = new CachingConfigurationSourceDecorator(innerSource.Object, new CacheKeyCreator(Guid.NewGuid().ToString()), MemoryCache.Default, () => new CacheItemPolicy()); return(source); }
protected override IConfigurationSource CreateConfigurationSource() { var objectCache = new Mock <ObjectCache>(); objectCache.Setup(x => x.Get(It.IsAny <string>(), It.IsAny <string>())) .Returns(ConfigurationSourceResult <TValue> .FailedResult()); var innerSource = new Mock <IConfigurationSource>(); innerSource.Setup(x => x.GetAppSettingAsync <TValue>(It.IsAny <string>(), It.IsAny <CancellationToken>())) .Throws(new Exception("Should never get here")); var source = new CachingConfigurationSourceDecorator(innerSource.Object, new CacheKeyCreator(Guid.NewGuid().ToString()), objectCache.Object, () => new CacheItemPolicy()); return(source); }