diff --git a/src/Microsoft.AspNet.Routing/Template/TemplateBinder.cs b/src/Microsoft.AspNet.Routing/Template/TemplateBinder.cs index 877286d874..17f259a193 100644 --- a/src/Microsoft.AspNet.Routing/Template/TemplateBinder.cs +++ b/src/Microsoft.AspNet.Routing/Template/TemplateBinder.cs @@ -292,7 +292,14 @@ namespace Microsoft.AspNet.Routing.Template return null; } - private static bool RoutePartsEqual(object a, object b) + + /// + /// Compares two objects for equality as parts of a case-insensitive path. + /// + /// An object to compare. + /// An object to compare. + /// True if the object are equal, otherwise false. + public static bool RoutePartsEqual(object a, object b) { var sa = a as string; var sb = b as string; diff --git a/test/Microsoft.AspNet.Routing.Tests/Template/TemplateBinderTests.cs b/test/Microsoft.AspNet.Routing.Tests/Template/TemplateBinderTests.cs index 9fdc2274fb..ac9c315663 100644 --- a/test/Microsoft.AspNet.Routing.Tests/Template/TemplateBinderTests.cs +++ b/test/Microsoft.AspNet.Routing.Tests/Template/TemplateBinderTests.cs @@ -1032,6 +1032,25 @@ namespace Microsoft.AspNet.Routing.Template.Tests expected); } + [Theory] + [InlineData(null, null, true)] + [InlineData("blog", null, false)] + [InlineData(null, "store", false)] + [InlineData("Cool", "cool", true)] + [InlineData("Co0l", "cool", false)] + public void RoutePartsEqualTest(object left, object right, bool expected) + { + // Arrange & Act & Assert + if (expected) + { + Assert.True(TemplateBinder.RoutePartsEqual(left, right)); + } + else + { + Assert.False(TemplateBinder.RoutePartsEqual(left, right)); + } + } + private static IInlineConstraintResolver GetInlineConstraintResolver() { var services = new ServiceCollection { OptionsServices.GetDefaultServices() };