public void AddItemToDictionary_ShouldIgnore_WhenKeyEmpty() { SortedDictionary <string, SortedList <string, string> > dict = new SortedDictionary <string, SortedList <string, string> >(); var owerName1 = "Daniel"; var color = "Black"; ListExtentions.AddItemToDictionary(dict, null, color, owerName1); Assert.Empty(dict.Keys); }
public void TestIsSingleData_SequenceTrue_ExactMatchFalse_IgnoreCaseTrue() { List <string> listActualValues = new List <string> { "abc", "abc", "pqr", "abc", "abc" }; string listExpectedValues = "abc"; bool areEqual = ListExtentions.VerifyListValues(listActualValues, listExpectedValues, true, true, false, false); Assert.AreEqual(true, areEqual); }
public void TestExactmatch_SequenceTrue_ExactMatchFalse_IgnoreCaseTrue() { List <string> listActualValues = new List <string> { "abc", "defg", "pqr", "uvw", "xyz" }; string listExpectedValues = "abc;def;pqr;uvw;xyz"; bool areEqual = ListExtentions.VerifyListValues(listActualValues, listExpectedValues, false, true, false, false); Assert.AreEqual(true, areEqual); }
public void AddItemToDictionary_ShouldIgnore_WhenValueEmpty() { SortedDictionary <string, SortedList <string, string> > dict = new SortedDictionary <string, SortedList <string, string> >(); var owerName1 = "Daniel"; var name = "Toyota"; var color = "Blue"; ListExtentions.AddItemToDictionary(dict, name, null, color); Assert.Empty(dict.Keys); ListExtentions.AddItemToDictionary(dict, name, owerName1, color); Assert.Single(dict.Keys); Assert.Single(dict[name]); ListExtentions.AddItemToDictionary(dict, name, null, color); Assert.Single(dict[name]); }
//Обменная поразрядная сортировка public static List <KeyValuePair <int, string> > SortAlgorithm5(this IList <KeyValuePair <int, string> > mass) { List <KeyValuePair <int, string> > result_mass = new List <KeyValuePair <int, string> >(); for (int z = 0; z < mass.Count; z++) { result_mass.Add(mass[z]); } var N = result_mass.Count; //R1 var l = 0; var r = N - 1; var b = 1; int j = 0; int i = 0; var m = 11; int flag = 0; int isO = 0; var MyStack = new List <int[]>(); do { do { //R2 if (l != r) { i = l; j = r; do { //R3 if (ListExtentions.GetBit(result_mass[i].Key, b, m) == 1) { int tempo = 1; do { //R6 j--; if (i <= j) { //R5 tempo = ListExtentions.GetBit(result_mass[j + 1].Key, b, m); if (tempo == 0) { //R7 result_mass.Swap(i, j + 1); i++; flag = 1; } } else { break; } } while (tempo != 0); if (flag == 0) { break; } }//R4 else { i++; } } while (i <= j); //R8 flag = 0; b++; if (b > m) { break; } else if (j == l) { l++; } else if ((j <= l) || (j == r)) { continue; } else { //R9 int[] temp = new int[2]; temp[0] = r; temp[1] = b; MyStack.Add(temp); r = j; } } else if (l == r) { break; } } while ((j <= l) || (j == r)); //R10 isO = 1; if (MyStack.Count > 0) { l = r + 1; int[] temp = new int[2]; temp = MyStack[MyStack.Count - 1]; r = temp[0]; b = temp[1]; MyStack.RemoveAt(MyStack.Count - 1); isO = 0; } } while (isO == 0); return(result_mass); }