public void DuplicateNullValues()
 {
     // Duplicate null values should be allowed, even if allowDuplicates is false.
       SynchronizedNotifyingCollection<string> collection = new SynchronizedNotifyingCollection<string>(true, false);
       collection.Add(null);
       collection.Add(null);
 }
예제 #2
0
        public void TestDuplicateElements()
        {
            SynchronizedNotifyingCollection <string> collection = new SynchronizedNotifyingCollection <string>(true, false);

            collection.Add("a");
            collection.Add(collection[0]);
        }
예제 #3
0
        public void TestNullElements3()
        {
            SynchronizedNotifyingCollection <string> collection = new SynchronizedNotifyingCollection <string>(false, true);

            collection.Add("a");
            collection[0] = null;
        }
예제 #4
0
        public void Test1()
        {
            _list = new List <string>();

            SynchronizedNotifyingCollection <string> collection = new SynchronizedNotifyingCollection <string>(false, false);

            collection.CollectionChanged += OnCollectionChanged;

            CompareCollections(_list, collection);

            collection.Add("a");
            Assert.AreEqual(1, collection.Count);
            CompareCollections(_list, collection);

            collection.Add("b");
            collection.Add("c");
            Assert.AreEqual(3, collection.Count);
            CompareCollections(_list, collection);

            collection[1] = "d";
            Assert.AreEqual(3, collection.Count);
            CompareCollections(_list, collection);

            collection[1] = collection[1];
            Assert.AreEqual(3, collection.Count);
            CompareCollections(_list, collection);

            collection.RemoveAt(0);
            Assert.AreEqual(2, collection.Count);
            CompareCollections(_list, collection);

            collection.Clear();
            CompareCollections(_list, collection);
            Assert.AreEqual(0, collection.Count);
        }
예제 #5
0
        public void DuplicateNullValues()
        {
            // Duplicate null values should be allowed, even if allowDuplicates is false.
            SynchronizedNotifyingCollection <string> collection = new SynchronizedNotifyingCollection <string>(true, false);

            collection.Add(null);
            collection.Add(null);
        }
예제 #6
0
        public void TestNullElements()
        {
            SynchronizedNotifyingCollection <string> collection = new SynchronizedNotifyingCollection <string>(false, true);

            collection.Add(null);

            // Duplicate null values should be allowed, even if AllowDuplicates is false.
            collection.Add(null);
        }
예제 #7
0
        public void TestAllowedNullsAndDuplicates()
        {
            SynchronizedNotifyingCollection <string> collection = new SynchronizedNotifyingCollection <string>(true, true);

            collection.Add(null);
            collection.Add("a");
            collection.Add(collection[1]);

            Assert.AreEqual(3, collection.Count);
        }
예제 #8
0
        public void TestDuplicateElements4()
        {
            SynchronizedNotifyingCollection <string> collection = new SynchronizedNotifyingCollection <string>(true, false);

            collection.Add("a");
            collection.Add("b");

            Assert.That(() => collection[1] = "a", Throws.ArgumentException);

            // But replacing the same item should work!
            collection[0] = "a";
        }
        public void GetEnumerator()
        {
            SynchronizedNotifyingCollection<string> collection = new SynchronizedNotifyingCollection<string>(true, false);
              collection.Add("a");
              collection.Add("b");

              var enumerator = collection.GetEnumerator();
              enumerator.MoveNext();
              Assert.AreEqual("a", enumerator.Current);
              enumerator.MoveNext();
              Assert.AreEqual("b", enumerator.Current);
        }
예제 #10
0
        public void GetEnumerator()
        {
            SynchronizedNotifyingCollection <string> collection = new SynchronizedNotifyingCollection <string>(true, false);

            collection.Add("a");
            collection.Add("b");

            var enumerator = collection.GetEnumerator();

            enumerator.MoveNext();
            Assert.AreEqual("a", enumerator.Current);
            enumerator.MoveNext();
            Assert.AreEqual("b", enumerator.Current);
        }
예제 #11
0
        public void MoveThrowsArgumentOutOfRangeException()
        {
            var c = new SynchronizedNotifyingCollection <int>();

            c.Add(1);
            c.Add(2);
            c.Add(3);
            c.Add(4);
            c.Add(5);

            Assert.Throws <ArgumentOutOfRangeException>(() => c.Move(-1, 1));
            Assert.Throws <ArgumentOutOfRangeException>(() => c.Move(5, 1));
            Assert.Throws <ArgumentOutOfRangeException>(() => c.Move(1, -1));
            Assert.Throws <ArgumentOutOfRangeException>(() => c.Move(-1, 5));
        }
        public void MoveTest()
        {
            var c = new SynchronizedNotifyingCollection<int>();
              c.Add(1);
              c.Add(2);
              c.Add(3);
              c.Add(4);
              c.Add(5);

              c.CollectionChanged += OnMove;

              c.Move(0, 0);   // Ok, does nothing.
              c.Move(1, 4);

              Assert.AreEqual(1, c[0]);
              Assert.AreEqual(3, c[1]);
              Assert.AreEqual(4, c[2]);
              Assert.AreEqual(5, c[3]);
              Assert.AreEqual(2, c[4]);

              Assert.AreEqual(5, c.Count);
        }
예제 #13
0
        public void MoveTest()
        {
            var c = new SynchronizedNotifyingCollection <int>();

            c.Add(1);
            c.Add(2);
            c.Add(3);
            c.Add(4);
            c.Add(5);

            c.CollectionChanged += OnMove;

            c.Move(0, 0); // Ok, does nothing.
            c.Move(1, 4);

            Assert.AreEqual(1, c[0]);
            Assert.AreEqual(3, c[1]);
            Assert.AreEqual(4, c[2]);
            Assert.AreEqual(5, c[3]);
            Assert.AreEqual(2, c[4]);

            Assert.AreEqual(5, c.Count);
        }
예제 #14
0
        public void TestRangeMethods()
        {
            _list = new List <string>();

            SynchronizedNotifyingCollection <string> collection = new SynchronizedNotifyingCollection <string>(false, false);

            collection.CollectionChanged += OnCollectionChanged;

            CompareCollections(_list, collection);

            collection.AddRange(new[] { "a", "b", "c" });
            Assert.AreEqual(3, collection.Count);
            Assert.AreEqual("a", collection[0]);
            Assert.AreEqual("b", collection[1]);
            Assert.AreEqual("c", collection[2]);
            CompareCollections(_list, collection);

            collection.AddRange(new[] { "d", "e" });
            Assert.AreEqual(5, collection.Count);
            Assert.AreEqual("d", collection[3]);
            Assert.AreEqual("e", collection[4]);
            CompareCollections(_list, collection);
        }
 public void TestDuplicateElements3()
 {
     SynchronizedNotifyingCollection<string> collection = new SynchronizedNotifyingCollection<string>(true, false);
       collection.Add("a");
       collection.Add("b");
       collection[0] = collection[1];
 }
 public void AddRangeShouldThrowWhenNull()
 {
     SynchronizedNotifyingCollection<string> collection = new SynchronizedNotifyingCollection<string>();
       collection.AddRange(null);
 }
        public void TestRangeMethods()
        {
            _list = new List<string>();

              SynchronizedNotifyingCollection<string> collection = new SynchronizedNotifyingCollection<string>(false, false);
              collection.CollectionChanged += OnCollectionChanged;

              CompareCollections(_list, collection);

              collection.AddRange(new[] { "a", "b", "c" });
              Assert.AreEqual(3, collection.Count);
              Assert.AreEqual("a", collection[0]);
              Assert.AreEqual("b", collection[1]);
              Assert.AreEqual("c", collection[2]);
              CompareCollections(_list, collection);

              collection.AddRange(new[] { "d", "e" });
              Assert.AreEqual(5, collection.Count);
              Assert.AreEqual("d", collection[3]);
              Assert.AreEqual("e", collection[4]);
              CompareCollections(_list, collection);
        }
 public void TestNullElements3()
 {
     SynchronizedNotifyingCollection<string> collection = new SynchronizedNotifyingCollection<string>(false, true);
       collection.Add("a");
       collection[0] = null;
 }
 public void TestNullElements2()
 {
     SynchronizedNotifyingCollection<string> collection = new SynchronizedNotifyingCollection<string>(false, true);
       collection.Insert(0, null);
 }
        public void TestNullElements()
        {
            SynchronizedNotifyingCollection<string> collection = new SynchronizedNotifyingCollection<string>(false, true);
              collection.Add(null);

              // Duplicate null values should be allowed, even if AllowDuplicates is false.
              collection.Add(null);
        }
        public void TestDuplicateElements4()
        {
            SynchronizedNotifyingCollection<string> collection = new SynchronizedNotifyingCollection<string>(true, false);
              collection.Add("a");
              collection.Add("b");

              Assert.That(() => collection[1] = "a", Throws.ArgumentException);

              // But replacing the same item should work!
              collection[0] = "a";
        }
 public void TestDuplicateElements2()
 {
     SynchronizedNotifyingCollection<string> collection = new SynchronizedNotifyingCollection<string>(true, false);
       collection.Add("a");
       collection.Add("b");
       collection.Insert(1, collection[0]);
 }
        public void TestAllowedNullsAndDuplicates()
        {
            SynchronizedNotifyingCollection<string> collection = new SynchronizedNotifyingCollection<string>(true, true);
              collection.Add(null);
              collection.Add("a");
              collection.Add(collection[1]);

              Assert.AreEqual(3, collection.Count);
        }
예제 #24
0
        public void TestNullElements2()
        {
            SynchronizedNotifyingCollection <string> collection = new SynchronizedNotifyingCollection <string>(false, true);

            collection.Insert(0, null);
        }
예제 #25
0
        public void AddRangeShouldThrowWhenNull()
        {
            SynchronizedNotifyingCollection <string> collection = new SynchronizedNotifyingCollection <string>();

            collection.AddRange(null);
        }
        public void MoveThrowsArgumentOutOfRangeException()
        {
            var c = new SynchronizedNotifyingCollection<int>();
              c.Add(1);
              c.Add(2);
              c.Add(3);
              c.Add(4);
              c.Add(5);

              Assert.Throws<ArgumentOutOfRangeException>(() => c.Move(-1, 1));
              Assert.Throws<ArgumentOutOfRangeException>(() => c.Move(5, 1));
              Assert.Throws<ArgumentOutOfRangeException>(() => c.Move(1, -1));
              Assert.Throws<ArgumentOutOfRangeException>(() => c.Move(-1, 5));
        }
        public void Test1()
        {
            _list = new List<string>();

              SynchronizedNotifyingCollection<string> collection = new SynchronizedNotifyingCollection<string>(false, false);
              collection.CollectionChanged += OnCollectionChanged;

              CompareCollections(_list, collection);

              collection.Add("a");
              Assert.AreEqual(1, collection.Count);
              CompareCollections(_list, collection);

              collection.Add("b");
              collection.Add("c");
              Assert.AreEqual(3, collection.Count);
              CompareCollections(_list, collection);

              collection[1] = "d";
              Assert.AreEqual(3, collection.Count);
              CompareCollections(_list, collection);

              collection[1] = collection[1];
              Assert.AreEqual(3, collection.Count);
              CompareCollections(_list, collection);

              collection.RemoveAt(0);
              Assert.AreEqual(2, collection.Count);
              CompareCollections(_list, collection);

              collection.Clear();
              CompareCollections(_list, collection);
              Assert.AreEqual(0, collection.Count);
        }