public void AllowsNullValues() { var observableDictionary = new FastObservableDictionary <int, object>(); observableDictionary.Add(1, null); Assert.IsNull(observableDictionary[1]); }
public void RaisesEventWhileAddingObject() { var counter = 0; var observableDictionary = new FastObservableDictionary <int, int>(); observableDictionary.AutomaticallyDispatchChangeNotifications = false; observableDictionary.CollectionChanged += (sender, args) => counter++; observableDictionary.Add((object)1, (object)1); Assert.AreEqual(1, counter); observableDictionary.Add((object)2, (object)2); Assert.AreEqual(2, counter); observableDictionary.Add((object)3, (object)3); Assert.AreEqual(3, counter); observableDictionary.Add((object)4, (object)4); Assert.AreEqual(4, counter); }
public void RaisesEventWhileAddingKvp() { var counter = 0; var observableDictionary = new FastObservableDictionary <int, int>(); observableDictionary.AutomaticallyDispatchChangeNotifications = false; observableDictionary.CollectionChanged += (sender, args) => counter++; observableDictionary.Add(new KeyValuePair <int, int>(1, 1)); Assert.AreEqual(1, counter); observableDictionary.Add(new KeyValuePair <int, int>(2, 2)); Assert.AreEqual(2, counter); observableDictionary.Add(new KeyValuePair <int, int>(3, 3)); Assert.AreEqual(3, counter); observableDictionary.Add(new KeyValuePair <int, int>(4, 4)); Assert.AreEqual(4, counter); }
public void RaiseEventWhileAddingStronglyTyped() { var counter = 0; var observableDictionary = new FastObservableDictionary <int, int>(); observableDictionary.AutomaticallyDispatchChangeNotifications = false; observableDictionary.CollectionChanged += (sender, args) => counter++; observableDictionary.Add(1, 1); Assert.AreEqual(1, counter); observableDictionary.Add(2, 2); Assert.AreEqual(2, counter); observableDictionary.Add(3, 3); Assert.AreEqual(3, counter); observableDictionary.Add(4, 4); Assert.AreEqual(4, counter); }
public void ThrowsArgumentNullExceptionForAddObject() { var observableDictionary = new FastObservableDictionary <int, int>(); Assert.That(() => observableDictionary.Add(1, null), Throws.ArgumentNullException); }
public void ThrowsInvalidCastExceptionForAddObject() { var observableDictionary = new FastObservableDictionary <int, int>(); Assert.That(() => observableDictionary.Add((object)"1", 1), Throws.TypeOf <InvalidCastException>()); }
public void ThrowsArgumentNullExceptionForNullKey() { var observableDictionary = new FastObservableDictionary <object, int>(); Assert.That(() => observableDictionary.Add(null, 1), Throws.ArgumentNullException); }