Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InteractiveExecutionInitialization" /> class.
 /// </summary>
 /// <param name="interactiveExecutionBehavior">Customization of interactive execution.</param>
 /// <param name="cacheInvalidator">Cache invalidator that will be used to create simple cache for creating interactive execution.</param>
 public InteractiveExecutionInitialization(InteractiveExecutionBehavior interactiveExecutionBehavior, CacheInvalidator cacheInvalidator = null)
 {
     InteractiveExecutionBehavior = interactiveExecutionBehavior;
     if (cacheInvalidator != null)
     {
         InteractiveExecutionCache = cacheInvalidator.CreateSimpleCache(CreateInteractiveExecution);
     }
     else
     {
         InteractiveExecutionCache = SimpleCache.Create(CreateInteractiveExecution);
     }
 }
Exemple #2
0
        public void Enumerate()
        {
            DictionaryCache <int, string> dictionaryCache;
            SimpleCache <int>             simpleCache;

            using (CacheInvalidator cacheInvalidator = new CacheInvalidator())
            {
                dictionaryCache = cacheInvalidator.CreateDictionaryCache <int, string>(key => key.ToString());
                simpleCache     = cacheInvalidator.CreateSimpleCache(() => 42);
                dictionaryCache.TryGetValue(simpleCache.Value, out string testValue);
                Assert.NotEmpty(cacheInvalidator);
            }
        }
Exemple #3
0
        public void ComplexTest()
        {
            DictionaryCache <int, string> dictionaryCache;
            SimpleCache <int>             simpleCache;

            using (CacheInvalidator cacheInvalidator = new CacheInvalidator())
            {
                dictionaryCache = cacheInvalidator.CreateDictionaryCache <int, string>(key => key.ToString());
                simpleCache     = cacheInvalidator.CreateSimpleCache(() => 42);
                dictionaryCache.TryGetValue(simpleCache.Value, out string testValue);
            }
            Assert.Equal(0, dictionaryCache.Count);
            Assert.False(simpleCache.Cached);
        }