public void SortByValueTest() { IDictionary<string, int> Test = new Dictionary<string, int>(); Test.Add("Q", 4); Test.Add("Z", 2); Test.Add("C", 3); Test.Add("A", 1); Test = Test.SortByValue(); string Value = ""; foreach (string Key in Test.Keys) Value += Test[Key].ToString(); Assert.Equal("1234", Value); }
public void SortByValue() { Dictionary<Int32, Char> input1 = new Dictionary<int, char>(3) { { 1, 'h' }, { 2, 'a' }, { 3, 'x' } }; Dictionary<Int32, Char> expected1 = new Dictionary<int, char>(3) { { 2, 'a' }, { 1, 'h' }, { 3, 'x' } }; Dictionary<Int32, Char> expected2 = new Dictionary<int, char>(3) { { 3, 'x' }, { 1, 'h' }, { 2, 'a' } }; CollectionAssert.AreEqual(expected1, input1.SortByValue(true)); CollectionAssert.AreEqual(expected2, input1.SortByValue(false)); }