public void Clear_Should_Delete_All_Values()
        {
            _singletonCache.Clear();

            Assert.Equal(0, _singletonCache.GetCount());
            Assert.Null(_singletonCache.GetOrNull("TestKey1"));
        }
Example #2
0
 private void Dispose(bool disposing)
 {
     if (!disposedValue)
     {
         if (disposing)
         {
             var disposables = (Root == this
                 ? SingletonCache.Union(scopedCache)
                 : scopedCache)
                               .Where(x => x.Value != this);
             foreach (var scoped in disposables)
             {
                 var disposable = scoped.Value as IDisposable;
                 disposable?.Dispose();
             }
             scopedCache.Clear();
             if (Root == this)
             {
                 SingletonCache.Clear();
             }
         }
         disposedValue = true;
     }
 }