diff --git a/src/Orchard.Tests/Orchard.Framework.Tests.csproj b/src/Orchard.Tests/Orchard.Framework.Tests.csproj
index 0ba5e7872..4efc87e3f 100644
--- a/src/Orchard.Tests/Orchard.Framework.Tests.csproj
+++ b/src/Orchard.Tests/Orchard.Framework.Tests.csproj
@@ -309,6 +309,7 @@
+
diff --git a/src/Orchard.Tests/Utility/Extensions/RouteValueDictionaryExtensionsTests.cs b/src/Orchard.Tests/Utility/Extensions/RouteValueDictionaryExtensionsTests.cs
new file mode 100644
index 000000000..47e7d19cb
--- /dev/null
+++ b/src/Orchard.Tests/Utility/Extensions/RouteValueDictionaryExtensionsTests.cs
@@ -0,0 +1,34 @@
+using System.Web.Routing;
+using NUnit.Framework;
+using Orchard.Utility.Extensions;
+
+namespace Orchard.Tests.Utility.Extensions {
+ [TestFixture]
+ class RouteValueDictionaryExtensionsTests {
+ [Test]
+ public void IdenticalRouteValueDictionariesShouldMatch() {
+ Assert.IsTrue(new RouteValueDictionary { { "controller", "foo" }, { "action", "bar" } }
+ .Match(new RouteValueDictionary { { "controller", "foo" }, { "action", "bar" } }));
+ }
+
+ [Test]
+ public void CasedRouteValueDictionariesShouldMatch() {
+ Assert.IsTrue(new RouteValueDictionary { { "controller", "foo" }, { "action", "BAR" } }
+ .Match(new RouteValueDictionary { { "controller", "foo" }, { "action", "bar" } }));
+ }
+
+ [Test]
+ public void RouteValueDictionariesWithDifferentNumbersOfValuesShouldNotMatch() {
+ Assert.IsFalse(new RouteValueDictionary { { "controller", "foo" }, { "action", "bar" } }
+ .Match(new RouteValueDictionary { { "controller", "foo" }, { "action", "bar" }, { "area", "baz" } }));
+
+ }
+
+ [Test]
+ public void RouteValueDictionariesWithDifferentValuesShouldMatch() {
+ Assert.IsFalse(new RouteValueDictionary { { "controller", "foo" }, { "action", "bar" } }
+ .Match(new RouteValueDictionary { { "controller", "foo" }, { "action", "baz" } }));
+
+ }
+ }
+}
diff --git a/src/Orchard/Utility/Extensions/RouteValueDictionaryExtensions.cs b/src/Orchard/Utility/Extensions/RouteValueDictionaryExtensions.cs
index 8b9fb0cf8..2c26d1fb7 100644
--- a/src/Orchard/Utility/Extensions/RouteValueDictionaryExtensions.cs
+++ b/src/Orchard/Utility/Extensions/RouteValueDictionaryExtensions.cs
@@ -35,8 +35,21 @@ namespace Orchard.Utility.Extensions {
return false;
}
- // keys can be different in case
- return x.Keys.All(key => x[key].ToString().Equals(y[key].ToString(), StringComparison.OrdinalIgnoreCase));
+ var bools = x.Join(y,
+ kv1 => kv1.Key.ToLowerInvariant(),
+ kv2 => kv2.Key.ToLowerInvariant(),
+ (kv1, kv2) => StringMatch(kv1.Value, kv2.Value)
+ ).ToArray();
+
+ return bools.All(b => b) && bools.Count() == x.Count;
+ }
+
+ private static bool StringMatch(object value1, object value2) {
+ return string.Equals(
+ Convert.ToString(value1, CultureInfo.InvariantCulture),
+ Convert.ToString(value2, CultureInfo.InvariantCulture),
+ StringComparison.InvariantCultureIgnoreCase
+ );
}
public static RouteValueDictionary ToRouteValueDictionary(this IEnumerable> routeValues) {