From 3eb6c22330ba74ca0c3858a9bc4df8278e07e3aa Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Mon, 7 Jul 2014 13:51:09 -0700 Subject: [PATCH] Make RoutePartsEqual public. --- .../Template/TemplateBinder.cs | 9 ++++++++- .../Template/TemplateBinderTests.cs | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) 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() };