public void Enable_bootstrapper_with_keys_and_array_string() { //Arrange var bootstrapper = new FakeDefaultBootstrapper(); var routeResolver = new FakeRouteResolver(); //Act RapidCache.Enable(bootstrapper, routeResolver, new FakePipelines(), new[] { "query", "form", "accept" }); //Assert Assert.True(RapidCache.IsCacheEnabled()); }
public void Disabled_bootstrapper_with_cache_removal_key() { //Arrange var bootstrapper = new FakeDefaultBootstrapper(); //Act Assert.Throws <BootstrapperException>(() => bootstrapper.EnableCacheRemovalKey(null)); //Assert Assert.False(RapidCache.IsCacheEnabled()); Assert.False(Defaults.DisableCache.Enabled); }
public void Enable_bootstrapper_with_keys() { //Arrange var bootstrapper = new FakeDefaultBootstrapper(); var routeResolver = new FakeRouteResolver(); //Act RapidCache.Enable(bootstrapper, routeResolver, new FakePipelines(), new DefaultCacheKeyGenerator()); //Assert Assert.True(RapidCache.IsCacheEnabled()); }
/// <summary> /// Enable the option of disability cache keys by a request, this option is off by default for security measurements. /// </summary> /// <param name="bootstrapper"></param> /// <param name="key"></param> public static void EnableCacheDisableKey(this INancyBootstrapper bootstrapper, string key = null) { if (!RapidCache.IsCacheEnabled()) { throw new BootstrapperException(DisableExceptionMessage); } Defaults.DisableCache.Enabled = true; if (!string.IsNullOrEmpty(key)) { Defaults.DisableCache.Key = key; } }
public void Enable_bootstrapper_with_cache_disable_key(string mockKey) { //Arrange var bootstrapper = new FakeDefaultBootstrapper(); var routeResolver = new FakeRouteResolver(); //Act RapidCache.Enable(bootstrapper, routeResolver, new FakePipelines()); bootstrapper.EnableCacheDisableKey(mockKey); //Assert Assert.True(RapidCache.IsCacheEnabled()); Assert.Equal(Defaults.DisableCache.Key, mockKey); Assert.True(Defaults.DisableCache.Enabled); }
public void Enable_bootstrapper_with_default_removal_key() { //Arrange var bootstrapper = new FakeDefaultBootstrapper(); var routeResolver = new FakeRouteResolver(); string mockKey = Defaults.RemoveCache.Key; //Act RapidCache.Enable(bootstrapper, routeResolver, new FakePipelines()); bootstrapper.EnableCacheRemovalKey(); //Assert Assert.True(RapidCache.IsCacheEnabled()); Assert.Equal(Defaults.RemoveCache.Key, mockKey); Assert.True(Defaults.RemoveCache.Enabled); }
/// <summary> /// Enables Nancy.RapidCache using the supplied parameters and CacheStore type /// </summary> /// <param name="bootstrapper"></param> /// <param name="routeResolver"> </param> /// <param name="pipelines"></param> /// <param name="cacheKeyGenerator"></param> /// <param name="cacheStore"> </param> public static void EnableRapidCache(this INancyBootstrapper bootstrapper, IRouteResolver routeResolver, IPipelines pipelines, ICacheKeyGenerator cacheKeyGenerator, ICacheStore cacheStore) => RapidCache.Enable(bootstrapper, routeResolver, pipelines, cacheKeyGenerator, cacheStore);
/// <summary> /// Enables Nancy.RapidCache using the supplied parameters and CacheStore type /// </summary> /// <param name="bootstrapper"></param> /// <param name="routeResolver"> </param> /// <param name="pipelines"></param> /// <param name="varyParams"></param> /// <param name="cacheStore"> </param> public static void EnableRapidCache(this INancyBootstrapper bootstrapper, IRouteResolver routeResolver, IPipelines pipelines, string[] varyParams, ICacheStore cacheStore) => RapidCache.Enable(bootstrapper, routeResolver, pipelines, new DefaultCacheKeyGenerator(varyParams), cacheStore);
/// <summary> /// Enables Nancy.RapidCache using the supplied parameters /// </summary> /// <param name="bootstrapper"></param> /// <param name="routeResolver"> </param> /// <param name="pipelines"></param> /// <param name="varyParams"></param> public static void EnableRapidCache(this INancyBootstrapper bootstrapper, IRouteResolver routeResolver, IPipelines pipelines, string[] varyParams) => RapidCache.Enable(bootstrapper, routeResolver, pipelines, varyParams);