Esempio n. 1
0
        public void TwoDifferentTypesWithTwoDifference()
        {
            int[]    Anumbers = new int[]    { 1, 2 };
            string[] Bstrings = new string[] { "2", "3" };

            List <string> newItemsInB = new List <string>();
            List <int>    delItemsInA = new List <int>();

            uint differences = 0;

            DiffAscendingSortedLists.NoModified <int, string>(
                Anumbers, Bstrings,
                KeyComparer: (numberA, stringB) => numberA.CompareTo(int.Parse(stringB)),
                KeySortOrderComparerA: (int i, int k) => i.CompareTo(k),
                KeySortOrderComparerB: (string i, string k) => String.Compare(i, k),
                OnNewB: bstring => { newItemsInB.Add(bstring); differences++; },
                OnDeleteA: aint => { delItemsInA.Add(aint); differences++; },
                OnSameSame: null);

            Assert.AreEqual <uint>(2, differences);
            Assert.AreEqual(1, newItemsInB.Count);
            Assert.AreEqual("3", newItemsInB[0]);
            Assert.AreEqual(1, delItemsInA.Count);
            Assert.AreEqual(1, delItemsInA[0]);
        }
Esempio n. 2
0
        public void NoExceptionWhenSelfComparerIsNull()
        {
            int[]    numbers = new int[] { 1, 2, 3 };
            string[] strings = new string[] { "1", "2", "3" };

            DiffAscendingSortedLists.NoModified <int, string>(
                ListA: numbers,
                ListB: strings,
                KeyComparer: (numberA, stringB) => numberA.CompareTo(int.Parse(stringB)),
                KeySortOrderComparerA: null,
                KeySortOrderComparerB: null,
                OnNewB: null, OnDeleteA: null, OnSameSame: null);
        }
Esempio n. 3
0
        public void TwoDifferentTypesButAllTheSame()
        {
            int[]    numbers = new int[] { 1, 2, 3 };
            string[] strings = new string[] { "1", "2", "3" };

            uint differences = 0;

            DiffAscendingSortedLists.NoModified <int, string>(numbers, strings,
                                                              KeyComparer: (numberA, stringB) => numberA.CompareTo(int.Parse(stringB)),
                                                              KeySortOrderComparerA: (int i, int k) => i.CompareTo(k),
                                                              KeySortOrderComparerB: (string i, string k) => String.Compare(i, k),
                                                              OnNewB: b => differences++,
                                                              OnDeleteA: a => differences++,
                                                              OnSameSame: null);

            Assert.AreEqual <uint>(0, differences);
        }