示例#1
0
        public static void RemoveTest()
        {
            // trying to remove item in collection.
            string[]           anArray = { "one", "two", "three", "four" };
            CiccioSet <string> col     = new CiccioSet <string>(anArray);
            CollectionAndPropertyChangedTester helper = new CollectionAndPropertyChangedTester();

            helper.RemoveItemTest(col, 2, "three", true, hasDuplicates: false);

            // trying to remove item not in collection.
            anArray = new string[] { "one", "two", "three", "four" };
            col     = new CiccioSet <string>(anArray);
            helper  = new CollectionAndPropertyChangedTester();
            helper.RemoveItemTest(col, -1, "three2", false, hasDuplicates: false);

            // removing null
            anArray = new string[] { "one", "two", "three", "four" };
            col     = new CiccioSet <string>(anArray);
            helper  = new CollectionAndPropertyChangedTester();
            helper.RemoveItemTest(col, -1, null, false, hasDuplicates: false);

            //// trying to remove item in collection that has duplicates.
            //anArray = new string[] { "one", "three", "two", "three", "four" };
            //col = new CiccioSet<string>(anArray);
            //helper = new CollectionAndPropertyChangedTester();
            //helper.RemoveItemTest(col, 1, "three", true, hasDuplicates: true);
            //// want to ensure that there is one "three" left in collection and not both were removed.
            //int occurrencesThree = 0;
            //foreach (var item in col)
            //{
            //    if (item.Equals("three"))
            //        occurrencesThree++;
            //}
            //Assert.Equal(1, occurrencesThree);
        }
示例#2
0
        public static void AddTest()
        {
            string[]           anArray = { "one", "two", "three" };
            CiccioSet <string> col     = new CiccioSet <string>(anArray);
            CollectionAndPropertyChangedTester helper = new CollectionAndPropertyChangedTester();

            helper.AddOrInsertItemTest(col, "four");
        }
示例#3
0
        public static void ClearTest()
        {
            string[]           anArray = { "one", "two", "three", "four" };
            CiccioSet <string> col     = new CiccioSet <string>(anArray);

            col.Clear();
            Assert.Equal(0, col.Count);
            Assert.Empty(col);

            //AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => col.ToArray()[1]);

            //tests that the collectionChanged events are fired.
            CollectionAndPropertyChangedTester helper = new CollectionAndPropertyChangedTester();

            col = new CiccioSet <string>(anArray);
            helper.ClearTest(col);
        }