public void When_set_maxretry_less_then_1_it_should_throw_argument_outofrange_exception() { var logger = Substitute.For <ILogger>(); Substitute.For <ICacheObserver>(); Assert.Throws <ArgumentOutOfRangeException>(() => { var options = new LocalCacheProviderOptions(logger, 0); }); }
public void When_not_set_default_options_maxretry_should_equals_to_1000() { var logger = Substitute.For <ILogger>(); var observer = Substitute.For <ICacheObserver>(); var options = new LocalCacheProviderOptions(logger); Assert.AreEqual(options.MaxRetryForLocalOperations, 1000); }
public void When_not_set_default_options_initialcapacity_should_equals_to_100() { var logger = Substitute.For <ILogger>(); var observer = Substitute.For <ICacheObserver>(); var options = new LocalCacheProviderOptions(logger); Assert.AreEqual(options.InitialCapacity, 100); }
public void When_not_set_default_options_concurrencylevel_should_equals_to_10() { var logger = Substitute.For <ILogger>(); var observer = Substitute.For <ICacheObserver>(); var options = new LocalCacheProviderOptions(logger); Assert.AreEqual(options.ConcurrencyLevel, 10); }
public void ConfigureAndUse() { // Every class should be single instance for AppDomain // Application name, desired to share same cache items var tribeName = "MyTribe"; // To seperate app instances, diagnostinc purposes, * Must ne unique: You can use Guid.NewGuid().ToString(); var memberName = "Beaver1"; //StackExchange.Redis connectionstring var redisConnectionString = "127.0.0.1:6379,abortConnect=false,defaultDatabase=1,keepAlive=300,resolveDns=false,synctimeout=5000,allowAdmin=true"; // Default Logger var logger = new ConsoleLogger(LogLevel.Info); // Default Serializer var serializer = new JsonNetSerializer(); //Redis Remote Cache Provider for Yakari var remoteCacheProvider = new RedisCacheProvider(redisConnectionString, serializer, logger); //Redis Subscription Manager for tribe communication. var subscriptionManager = new RedisSubscriptionManager(redisConnectionString, tribeName, logger); // Options class for LittleThunder. var localCacheProviderOptions = new LocalCacheProviderOptions(); // Little Thunder the Local Cache Provider var localCacheProvider = new LittleThunder(localCacheProviderOptions, logger); // The Great Eagle var observer = new GreatEagle(memberName, subscriptionManager, serializer, localCacheProvider, remoteCacheProvider, logger); // Great eagle start observing and loads every previous remote cache items in seperate thread // Usage var key = "pebbles"; // Simple Set localCacheProvider.Set(key, new[] { "pebble1", "pebble2", "pebble3" }, CacheTime.FifteenMinutes, false); // Simple Get var pebbles = localCacheProvider.Get <string[]>(key, TimeSpan.FromSeconds(5), false); // Get with Acquire Function *Recommended var item = localCacheProvider.Get <string[]>(key, TimeSpan.FromSeconds(5), () => { return(new[] { "pebble1", "pebble2", "pebble3" }); }, CacheTime.FifteenMinutes, false); // Simple Delete localCacheProvider.Delete(key, false); }
public void When_logger_is_null_should_throw_argument_null_exception() { Assert.Throws <ArgumentNullException>(() => { var options = new LocalCacheProviderOptions(null); }); }
public void When_all_options_are_blank_Then_it_should_throw_argument_null_exception() { Assert.Throws <ArgumentNullException>(() => { var options = new LocalCacheProviderOptions(null); }); }
public void When_not_set_default_options_maxretry_should_equals_to_1000() { var options = new LocalCacheProviderOptions(); Assert.AreEqual(options.MaxRetryForLocalOperations, 1000); }
public void When_not_set_default_options_initialcapacity_should_equals_to_100() { var options = new LocalCacheProviderOptions(); Assert.AreEqual(options.InitialCapacity, 100); }
public void When_not_set_default_options_concurrencylevel_should_equals_to_10() { var options = new LocalCacheProviderOptions(); Assert.AreEqual(options.ConcurrencyLevel, 10); }
public void When_set_maxretry_less_then_1_it_should_throw_argument_outofrange_exception() { Assert.Throws <ArgumentOutOfRangeException>(() => { var options = new LocalCacheProviderOptions(0); }); }