public void Test_ConcurrentObservableDictionary_Clear()
        {
            var initial    = Enumerable.Range(0, 100).Select(x => new KeyValuePair <int, int>(x, x));
            var collection = new ConcurrentObservableDictionary <int, int>();

            collection.AddRange(initial);
            Assert.AreEqual(100, collection.Count);

            // Record all the collection changed events
            List <(object, NotifyCollectionChangedEventArgs)> returnedList = new List <(object, NotifyCollectionChangedEventArgs)>();

            collection.CollectionChanged += (s, e) => returnedList.Add((s, e));

            collection.Clear();

            // Check just one collection changed event was fired
            Assert.AreEqual(1, returnedList.Count);
            (var returnedObject, var returnedArgs) = returnedList[0];

            Assert.AreEqual(0, collection.Count);

            Assert.AreEqual(returnedObject, collection);
            Assert.AreEqual(NotifyCollectionChangedAction.Remove, returnedArgs.Action);

            Assert.IsNull(returnedArgs.NewItems);

            Assert.IsNotNull(returnedArgs.OldItems);
            Assert.AreEqual(initial.Count(), returnedArgs.OldItems.Count);
            Assert.IsTrue(initial.Zip(returnedArgs.OldItems.OfType <KeyValuePair <int, int> >(), (a, b) => a.Key == b.Key && a.Value == b.Value).All(c => c));
        }
        public void TestClearCache()
        {
            var data = new ConcurrentObservableDictionary <string, double>();
            var obs  = new SimpleObserver();

            data.AddPartialObserver(obs, "test", "test2", "test3");

            data.AddOrUpdate("test", 2.0);
            data.AddOrUpdate("test2", 12.0);
            data.AddOrUpdate("test3", 32.0);
            Assert.IsFalse(data.IsEmpty, "data is empty");

            data.Clear();
            Assert.IsTrue(data.IsEmpty, "data is not empty");
        }
示例#3
0
 public void UnsubscribeAll() => CachedKeys.Clear();
示例#4
0
 public void ClearCache() => Cache.Clear();
示例#5
0
 public void Clear() => _blocks.Clear();
示例#6
0
 public void ClearCache()
 {
     Cache.Clear();
 }