public void KeyComparisonNullException() { int[] numbers = new int[] { 1, 2, 3 }; string[] strings = new string[] { "1", "2", "3" }; DiffAscendingSortedLists.Run <int, string, object>( ListA: numbers, ListB: strings, KeyComparer: null, KeySortOrderComparerA: null, KeySortOrderComparerB: null, AttributeComparer: null, OnNewB: null, OnDeleteA: null, OnModified: null, OnSameSame: null); }
public void TwoDifferentTypesWithModifications() { double[] Anumbers = new double[] { 1, 2.5f }; string[] Bstrings = new string[] { "1", "2,3" }; List <string> newItemsInB = new List <string>(); List <double> delItemsInA = new List <double>(); List <Tuple <double, string> > modList = new List <Tuple <double, string> >(); uint differences = 0; DiffAscendingSortedLists.Run( Anumbers, Bstrings, KeyComparer: (numberA, stringB) => { int numberIntA = (int)(numberA); int numberIntB = (int)(double.Parse(stringB)); return(numberIntA.CompareTo(numberIntB)); }, AttributeComparer: (double a, string b, out double diff) => { double restA = a - Math.Floor(a); string[] parts = b.Split(','); string restB = parts.Length == 2 ? parts[1] : String.Empty; double dblRestB = Convert.ToDouble("0," + restB); diff = dblRestB - restA; return(restA.Equals(dblRestB)); }, KeySortOrderComparerA: (double i, double k) => i.CompareTo(k), KeySortOrderComparerB: (string i, string k) => String.Compare(i, k), OnModified: (double num, string str, double diff) => { modList.Add(Tuple.Create(num, str)); differences++; }, OnNewB: null, OnDeleteA: null, OnSameSame: null); Assert.AreEqual <uint>(1, differences); Assert.AreEqual(0, newItemsInB.Count); Assert.AreEqual(0, delItemsInA.Count); Assert.AreEqual(1, modList.Count); Assert.AreEqual(2.5f, modList[0].Item1); Assert.AreEqual("2,3", modList[0].Item2); }