コード例 #1
0
            public void AllowsNullValues()
            {
                var observableDictionary = new FastObservableDictionary <int, object>();

                observableDictionary.Add(1, null);

                Assert.IsNull(observableDictionary[1]);
            }
コード例 #2
0
            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);
            }
コード例 #3
0
            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);
            }
コード例 #4
0
            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);
            }
コード例 #5
0
            public void ThrowsArgumentNullExceptionForAddObject()
            {
                var observableDictionary = new FastObservableDictionary <int, int>();

                Assert.That(() => observableDictionary.Add(1, null), Throws.ArgumentNullException);
            }
コード例 #6
0
            public void ThrowsInvalidCastExceptionForAddObject()
            {
                var observableDictionary = new FastObservableDictionary <int, int>();

                Assert.That(() => observableDictionary.Add((object)"1", 1), Throws.TypeOf <InvalidCastException>());
            }
コード例 #7
0
            public void ThrowsArgumentNullExceptionForNullKey()
            {
                var observableDictionary = new FastObservableDictionary <object, int>();

                Assert.That(() => observableDictionary.Add(null, 1), Throws.ArgumentNullException);
            }