public void TestGetCombinedDictionaryNonEmpty() { // Case 1: Dictionaries have mutually exclusive sets of keys. var firstDictionary = new Dictionary <string, string> { { "a", "A" }, { "b", "B" } }; var secondDictionary = new Dictionary <string, string> { { "c", "C" }, { "d", "D" } }; var firstAndSecondDictionary = HttpRequestHelper.GetCombinedDictionary(secondDictionary, firstDictionary); Assert.AreEqual(new Dictionary <string, string> { { "a", "A" }, { "b", "B" }, { "c", "C" }, { "d", "D" } }, firstAndSecondDictionary); // Case 2: Dictionaries share keys. Keys in the second dictionary override keys in the first. var thirdDictionary = new Dictionary <string, string> { { "a", "1" }, { "b", "2" } }; var fourthDictionary = new Dictionary <string, string> { { "b", "3" }, { "c", "4" } }; var thirdAndFourthDictionary = HttpRequestHelper.GetCombinedDictionary(thirdDictionary, fourthDictionary); Assert.AreEqual(new Dictionary <string, string> { { "a", "1" }, { "b", "3" }, { "c", "4" } }, thirdAndFourthDictionary); }
public void TestGetCombinedDictionaryNullOrEmpty() { var emptyDictionary = new Dictionary <string, string>(); var nonEmptyDictionary = new Dictionary <string, string> { { "a", "b" } }; // Case 1: Null dictionaries Assert.AreEqual(nonEmptyDictionary, HttpRequestHelper.GetCombinedDictionary(nonEmptyDictionary, null)); Assert.AreEqual(nonEmptyDictionary, HttpRequestHelper.GetCombinedDictionary(null, nonEmptyDictionary)); Assert.AreEqual(emptyDictionary, HttpRequestHelper.GetCombinedDictionary(null, null)); // Case 2 : Empty Dictionaries Assert.AreEqual(emptyDictionary, HttpRequestHelper.GetCombinedDictionary(emptyDictionary, emptyDictionary)); Assert.AreEqual(nonEmptyDictionary, HttpRequestHelper.GetCombinedDictionary(emptyDictionary, nonEmptyDictionary)); Assert.AreEqual(nonEmptyDictionary, HttpRequestHelper.GetCombinedDictionary(nonEmptyDictionary, emptyDictionary)); }