public static void SortedDictionary_ValueCollectionTest2() { IntGenerator intGenerator = new IntGenerator(); StringGenerator stringGenerator = new StringGenerator(); intGenerator.NextValue(); stringGenerator.NextValue(); Driver <int, int> intDriver = new Driver <int, int>(); Driver <SimpleRef <String>, SimpleRef <String> > simpleRef = new Driver <SimpleRef <String>, SimpleRef <String> >(); Driver <SimpleRef <int>, SimpleRef <int> > simpleVal = new Driver <SimpleRef <int>, SimpleRef <int> >(); //Scenario 3: Check the underlying reference. Change the SortedDictionary afterwards and examine ICollection keys and make sure that the //change is reflected int count = 100; SimpleRef <int>[] simpleInts = SortedDictionaryUtils.GetSimpleInts(count); SimpleRef <String>[] simpleStrings = SortedDictionaryUtils.GetSimpleStrings(count); int[] ints = new int[count]; int half = count / 2; SimpleRef <int>[] simpleInts_1 = new SimpleRef <int> [half]; SimpleRef <String>[] simpleStrings_1 = new SimpleRef <String> [half]; SimpleRef <int>[] simpleInts_2 = new SimpleRef <int> [half]; SimpleRef <String>[] simpleStrings_2 = new SimpleRef <String> [half]; for (int i = 0; i < count; i++) { ints[i] = i; } int[] ints_1 = new int[half]; int[] ints_2 = new int[half]; for (int i = 0; i < half; i++) { simpleInts_1[i] = simpleInts[i]; simpleStrings_1[i] = simpleStrings[i]; ints_1[i] = ints[i]; simpleInts_2[i] = simpleInts[i + half]; simpleStrings_2[i] = simpleStrings[i + half]; ints_2[i] = ints[i + half]; } intDriver.TestModify(ints_1, ints_1, ints_2); simpleRef.TestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2); simpleVal.TestModify(simpleInts_1, simpleInts_1, simpleInts_2); intDriver.NonGenericIDictionaryTestModify(ints_1, ints_1, ints_2); simpleRef.NonGenericIDictionaryTestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2); simpleVal.NonGenericIDictionaryTestModify(simpleInts_1, simpleInts_1, simpleInts_2); }
public static void SortedDictionary_ValueCollectionTest_Negative() { IntGenerator intGenerator = new IntGenerator(); StringGenerator stringGenerator = new StringGenerator(); intGenerator.NextValue(); stringGenerator.NextValue(); //Scenario 1: Vanilla - fill in SortedDictionary with 10 keys and check this property Driver <int, int> IntDriver = new Driver <int, int>(); Driver <SimpleRef <String>, SimpleRef <String> > simpleRef = new Driver <SimpleRef <String>, SimpleRef <String> >(); Driver <SimpleRef <int>, SimpleRef <int> > simpleVal = new Driver <SimpleRef <int>, SimpleRef <int> >(); int count = 100; SimpleRef <int>[] simpleInts = SortedDictionaryUtils.GetSimpleInts(count); SimpleRef <String>[] simpleStrings = SortedDictionaryUtils.GetSimpleStrings(count); int[] ints = new int[count]; for (int i = 0; i < count; i++) { ints[i] = i; } IntDriver.TestVanilla_Negative(ints, ints); simpleRef.TestVanilla_Negative(simpleStrings, simpleStrings); simpleVal.TestVanilla_Negative(simpleInts, simpleInts); IntDriver.NonGenericIDictionaryTestVanilla_Negative(ints, ints); simpleRef.NonGenericIDictionaryTestVanilla_Negative(simpleStrings, simpleStrings); simpleVal.NonGenericIDictionaryTestVanilla_Negative(simpleInts, simpleInts); //Scenario 2: Check for an empty SortedDictionary IntDriver.TestVanilla_Negative(new int[0], new int[0]); simpleRef.TestVanilla_Negative(new SimpleRef <String> [0], new SimpleRef <String> [0]); simpleVal.TestVanilla_Negative(new SimpleRef <int> [0], new SimpleRef <int> [0]); IntDriver.NonGenericIDictionaryTestVanilla_Negative(new int[0], new int[0]); simpleRef.NonGenericIDictionaryTestVanilla_Negative(new SimpleRef <String> [0], new SimpleRef <String> [0]); simpleVal.NonGenericIDictionaryTestVanilla_Negative(new SimpleRef <int> [0], new SimpleRef <int> [0]); }
public static void SortedDictionary_KeyCollectionTest1() { IntGenerator intGenerator = new IntGenerator(); StringGenerator stringGenerator = new StringGenerator(); intGenerator.NextValue(); stringGenerator.NextValue(); //Scenario 1: Vanilla - fill in an SortedDictionary with 10 keys and check this property Driver <int, int> IntDriver = new Driver <int, int>(); Driver <SimpleRef <String>, SimpleRef <String> > simpleRef = new Driver <SimpleRef <String>, SimpleRef <String> >(); Driver <SimpleRef <int>, SimpleRef <int> > simpleVal = new Driver <SimpleRef <int>, SimpleRef <int> >(); int count = 1000; SimpleRef <int>[] simpleInts = SortedDictionaryUtils.GetSimpleInts(count); SimpleRef <String>[] simpleStrings = SortedDictionaryUtils.GetSimpleStrings(count); int[] ints = new int[count]; for (int i = 0; i < count; i++) { ints[i] = i; } IntDriver.TestVanilla(ints, ints); simpleRef.TestVanilla(simpleStrings, simpleStrings); simpleVal.TestVanilla(simpleInts, simpleInts); IntDriver.NonGenericIDictionaryTestVanilla(ints, ints); simpleRef.NonGenericIDictionaryTestVanilla(simpleStrings, simpleStrings); simpleVal.NonGenericIDictionaryTestVanilla(simpleInts, simpleInts); //Scenario 2: Check for an empty SortedDictionary IntDriver.TestVanilla(new int[0], new int[0]); simpleRef.TestVanilla(new SimpleRef <String> [0], new SimpleRef <String> [0]); simpleVal.TestVanilla(new SimpleRef <int> [0], new SimpleRef <int> [0]); IntDriver.NonGenericIDictionaryTestVanilla(new int[0], new int[0]); simpleRef.NonGenericIDictionaryTestVanilla(new SimpleRef <String> [0], new SimpleRef <String> [0]); simpleVal.NonGenericIDictionaryTestVanilla(new SimpleRef <int> [0], new SimpleRef <int> [0]); //Scenario 3: Check the underlying reference. Change the SortedDictionary afterwards and examine ICollection keys and make sure that the //change is reflected int half = count / 2; SimpleRef <int>[] simpleInts_1 = new SimpleRef <int> [half]; SimpleRef <String>[] simpleStrings_1 = new SimpleRef <String> [half]; SimpleRef <int>[] simpleInts_2 = new SimpleRef <int> [half]; SimpleRef <String>[] simpleStrings_2 = new SimpleRef <String> [half]; int[] ints_1 = new int[half]; int[] ints_2 = new int[half]; for (int i = 0; i < half; i++) { simpleInts_1[i] = simpleInts[i]; simpleStrings_1[i] = simpleStrings[i]; ints_1[i] = ints[i]; simpleInts_2[i] = simpleInts[i + half]; simpleStrings_2[i] = simpleStrings[i + half]; ints_2[i] = ints[i + half]; } IntDriver.TestModify(ints_1, ints_1, ints_2); simpleRef.TestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2); simpleVal.TestModify(simpleInts_1, simpleInts_1, simpleInts_2); IntDriver.NonGenericIDictionaryTestModify(ints_1, ints_1, ints_2); simpleRef.NonGenericIDictionaryTestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2); simpleVal.NonGenericIDictionaryTestModify(simpleInts_1, simpleInts_1, simpleInts_2); }