コード例 #1
0
 public static void AddTest()
 {
     string[] anArray = { "one", "two", "three" };
     ObservableCollection<string> col = new ObservableCollection<string>(anArray);
     ReadOnlyObservableCollection<string> readonlyCol = new ReadOnlyObservableCollection<string>(col);
     ReadOnlyCollectionAndPropertyChangedTester helper = new ReadOnlyCollectionAndPropertyChangedTester();
     helper.AddOrInsertItemTest(readonlyCol, col, "four");
 }
コード例 #2
0
        public static void AddTest()
        {
            string[] anArray = { "one", "two", "three" };
            ObservableCollection <string>              col         = new ObservableCollection <string>(anArray);
            ReadOnlyObservableCollection <string>      readonlyCol = new ReadOnlyObservableCollection <string>(col);
            ReadOnlyCollectionAndPropertyChangedTester helper      = new ReadOnlyCollectionAndPropertyChangedTester();

            helper.AddOrInsertItemTest(readonlyCol, col, "four");
        }
コード例 #3
0
        public static void RemoveAtTest()
        {
            string[] anArrayString = { "one", "two", "three", "four" };
            ObservableCollection <string>              col         = new ObservableCollection <string>(anArrayString);
            ReadOnlyObservableCollection <string>      readonlyCol = new ReadOnlyObservableCollection <string>(col);
            ReadOnlyCollectionAndPropertyChangedTester helper      = new ReadOnlyCollectionAndPropertyChangedTester();

            helper.RemoveItemAtTest(readonlyCol, col, 1);
        }
コード例 #4
0
 public static void ClearTest()
 {
     string[] anArray = { "one", "two", "three", "four" };
     //tests that the collectionChanged events are fired.
     ReadOnlyCollectionAndPropertyChangedTester helper = new ReadOnlyCollectionAndPropertyChangedTester();
     ObservableCollection<string> col = new ObservableCollection<string>(anArray);
     ReadOnlyObservableCollection<string> readonlyCol = new ReadOnlyObservableCollection<string>(col);
     helper.ClearTest(readonlyCol, col);
 }
コード例 #5
0
        public static void ClearTest()
        {
            string[] anArray = { "one", "two", "three", "four" };
            //tests that the collectionChanged events are fired.
            ReadOnlyCollectionAndPropertyChangedTester helper = new ReadOnlyCollectionAndPropertyChangedTester();
            ObservableCollection <string>         col         = new ObservableCollection <string>(anArray);
            ReadOnlyObservableCollection <string> readonlyCol = new ReadOnlyObservableCollection <string>(col);

            helper.ClearTest(readonlyCol, col);
        }
コード例 #6
0
        public static void ReplaceItemTest()
        {
            string[] anArray = new string[] { "one", "two", "three", "four" };
            ObservableCollection <string>              collection  = new ObservableCollection <string>(anArray);
            ReadOnlyObservableCollection <string>      readonlyCol = new ReadOnlyObservableCollection <string>(collection);
            ReadOnlyCollectionAndPropertyChangedTester helper      = new ReadOnlyCollectionAndPropertyChangedTester();

            helper.ReplaceItemTest(readonlyCol, collection, 1, "seven");
            helper.ReplaceItemTest(readonlyCol, collection, 3, "zero");
        }
コード例 #7
0
        public static void InsertTest()
        {
            string[] anArrayString = new string[] { "one", "two", "three", "four" };
            ObservableCollection <string>              collection  = new ObservableCollection <string>(anArrayString);
            ReadOnlyObservableCollection <string>      readonlyCol = new ReadOnlyObservableCollection <string>(collection);
            ReadOnlyCollectionAndPropertyChangedTester helper      = new ReadOnlyCollectionAndPropertyChangedTester();

            helper.AddOrInsertItemTest(readonlyCol, collection, "seven", 2);
            helper.AddOrInsertItemTest(readonlyCol, collection, "zero", 0);
            helper.AddOrInsertItemTest(readonlyCol, collection, "eight", collection.Count);
        }
コード例 #8
0
        public static void MoveTest()
        {
            ReadOnlyCollectionAndPropertyChangedTester helper = new ReadOnlyCollectionAndPropertyChangedTester();

            string[] anArrayString = new string[] { "one", "two", "three", "four" };
            ObservableCollection <string>         collection  = new ObservableCollection <string>(anArrayString);
            ReadOnlyObservableCollection <string> readonlyCol = new ReadOnlyObservableCollection <string>(collection);

            helper.MoveItemTest(readonlyCol, collection, 0, 2);
            helper.MoveItemTest(readonlyCol, collection, 3, 0);
            helper.MoveItemTest(readonlyCol, collection, 1, 2);
        }
コード例 #9
0
        public static void RemoveTest()
        {
            // trying to remove item in collection.
            string[] anArray = { "one", "two", "three", "four" };
            ObservableCollection <string>              col         = new ObservableCollection <string>(anArray);
            ReadOnlyObservableCollection <string>      readonlyCol = new ReadOnlyObservableCollection <string>(col);
            ReadOnlyCollectionAndPropertyChangedTester helper      = new ReadOnlyCollectionAndPropertyChangedTester();

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

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

            // removing null
            anArray     = new string[] { "one", "two", "three", "four" };
            col         = new ObservableCollection <string>(anArray);
            readonlyCol = new ReadOnlyObservableCollection <string>(col);
            helper      = new ReadOnlyCollectionAndPropertyChangedTester();
            helper.RemoveItemTest(readonlyCol, 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 ObservableCollection <string>(anArray);
            readonlyCol = new ReadOnlyObservableCollection <string>(col);
            helper      = new ReadOnlyCollectionAndPropertyChangedTester();
            helper.RemoveItemTest(readonlyCol, 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);
        }
コード例 #10
0
        public static void RemoveTest()
        {
            // trying to remove item in collection.
            string[] anArray = { "one", "two", "three", "four" };
            ObservableCollection<string> col = new ObservableCollection<string>(anArray);
            ReadOnlyObservableCollection<string> readonlyCol = new ReadOnlyObservableCollection<string>(col);
            ReadOnlyCollectionAndPropertyChangedTester helper = new ReadOnlyCollectionAndPropertyChangedTester();
            helper.RemoveItemTest(readonlyCol, col, 2, "three", true, hasDuplicates: false);

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

            // removing null
            anArray = new string[] { "one", "two", "three", "four" };
            col = new ObservableCollection<string>(anArray);
            readonlyCol = new ReadOnlyObservableCollection<string>(col);
            helper = new ReadOnlyCollectionAndPropertyChangedTester();
            helper.RemoveItemTest(readonlyCol, 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 ObservableCollection<string>(anArray);
            readonlyCol = new ReadOnlyObservableCollection<string>(col);
            helper = new ReadOnlyCollectionAndPropertyChangedTester();
            helper.RemoveItemTest(readonlyCol, col, 1, "three", true, hasDuplicates: true);
            // want to ensure that there is one "three" left in collection and not both were removed.
            int occurancesThree = 0;
            foreach (var item in col)
            {
                if (item.Equals("three"))
                    occurancesThree++;
            }
            Assert.Equal(1, occurancesThree);
        }
コード例 #11
0
 public static void RemoveAtTest()
 {
     string[] anArrayString = { "one", "two", "three", "four" };
     ObservableCollection<string> col = new ObservableCollection<string>(anArrayString);
     ReadOnlyObservableCollection<string> readonlyCol = new ReadOnlyObservableCollection<string>(col);
     ReadOnlyCollectionAndPropertyChangedTester helper = new ReadOnlyCollectionAndPropertyChangedTester();
     helper.RemoveItemAtTest(readonlyCol, col, 1);
 }
コード例 #12
0
 public static void ReplaceItemTest()
 {
     string[] anArray = new string[] { "one", "two", "three", "four" };
     ObservableCollection<string> collection = new ObservableCollection<string>(anArray);
     ReadOnlyObservableCollection<string> readonlyCol = new ReadOnlyObservableCollection<string>(collection);
     ReadOnlyCollectionAndPropertyChangedTester helper = new ReadOnlyCollectionAndPropertyChangedTester();
     helper.ReplaceItemTest(readonlyCol, collection, 1, "seven");
     helper.ReplaceItemTest(readonlyCol, collection, 3, "zero");
 }
コード例 #13
0
 public static void InsertTest()
 {
     string[] anArrayString = new string[] { "one", "two", "three", "four" };
     ObservableCollection<string> collection = new ObservableCollection<string>(anArrayString);
     ReadOnlyObservableCollection<string> readonlyCol = new ReadOnlyObservableCollection<string>(collection);
     ReadOnlyCollectionAndPropertyChangedTester helper = new ReadOnlyCollectionAndPropertyChangedTester();
     helper.AddOrInsertItemTest(readonlyCol, collection, "seven", 2);
     helper.AddOrInsertItemTest(readonlyCol, collection, "zero", 0);
     helper.AddOrInsertItemTest(readonlyCol, collection, "eight", collection.Count);
 }
コード例 #14
0
 public static void MoveTest()
 {
     ReadOnlyCollectionAndPropertyChangedTester helper = new ReadOnlyCollectionAndPropertyChangedTester();
     string[] anArrayString = new string[] { "one", "two", "three", "four" };
     ObservableCollection<string> collection = new ObservableCollection<string>(anArrayString);
     ReadOnlyObservableCollection<string> readonlyCol = new ReadOnlyObservableCollection<string>(collection);
     helper.MoveItemTest(readonlyCol, collection, 0, 2);
     helper.MoveItemTest(readonlyCol, collection, 3, 0);
     helper.MoveItemTest(readonlyCol, collection, 1, 2);
 }