Make RoutePartsEqual public.

This commit is contained in:
Ryan Nowak 2014-07-07 13:51:09 -07:00
parent 038802ee45
commit 3eb6c22330
2 changed files with 27 additions and 1 deletions

View File

@ -292,7 +292,14 @@ namespace Microsoft.AspNet.Routing.Template
return null;
}
private static bool RoutePartsEqual(object a, object b)
/// <summary>
/// Compares two objects for equality as parts of a case-insensitive path.
/// </summary>
/// <param name="a">An object to compare.</param>
/// <param name="b">An object to compare.</param>
/// <returns>True if the object are equal, otherwise false.</returns>
public static bool RoutePartsEqual(object a, object b)
{
var sa = a as string;
var sb = b as string;

View File

@ -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() };