[linqbridge] push by azizatif - Fixed issue #20: ToDictionary overload ignores comparer on 2011-04-30 19:06 GMT

0 views
Skip to first unread message

linqb...@googlecode.com

unread,
Apr 30, 2011, 3:11:08 PM4/30/11
to linqbridg...@googlegroups.com
Revision: c8b5b8ba1fbc
Author: azizatif
Date: Sat Apr 30 12:06:40 2011
Log: Fixed issue #20: ToDictionary overload ignores comparer
http://code.google.com/p/linqbridge/source/detail?r=c8b5b8ba1fbc

Modified:
/src/Enumerable.cs
/test/LINQBridge.Tests/EnumerableFixture.cs

=======================================
--- /src/Enumerable.cs Sat Apr 30 06:02:19 2011
+++ /src/Enumerable.cs Sat Apr 30 12:06:40 2011
@@ -1610,7 +1610,7 @@
Func<TSource, TKey> keySelector,
IEqualityComparer<TKey> comparer)
{
- return source.ToDictionary(keySelector, e => e);
+ return source.ToDictionary(keySelector, e => e, comparer);
}

/// <summary>
=======================================
--- /test/LINQBridge.Tests/EnumerableFixture.cs Sat Apr 30 07:13:04 2011
+++ /test/LINQBridge.Tests/EnumerableFixture.cs Sat Apr 30 12:06:40 2011
@@ -2128,6 +2128,18 @@
check++;
}
}
+
+ [Test]
+ public void
ToDictionary_KeySelectorArg_ValidArguments_ComparerIsUsedForKeysInDictionary()
+ {
+ var source = Read("foo", "bar", "baz");
+ var result = source.ToDictionary(s => s,
StringComparer.OrdinalIgnoreCase);
+ Assert.AreEqual("foo", result["FOO"]);
+ Assert.AreEqual("foo", result["foo"]);
+ Assert.AreEqual("foo", result["FoO"]);
+ Assert.AreEqual("bar", result["BAR"]);
+ Assert.AreEqual("baz", result["BAZ"]);
+ }

[Test]
public void
ToList_IntsFromOneToTen_ReturnsListOfIntsContainingAllElements()

Reply all
Reply to author
Forward
0 new messages