Skip to content

Commit 2314f16

Browse files
committed
Route and RoutePrefix templates now perform case insensitive checks (closes #205)
1 parent dba755f commit 2314f16

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

src/MyWebApi.Tests/BuildersTests/AttributesTests/ActionAttributesTestBuilderTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ public void ChangingRouteToShouldNotThrowExceptionWithActionWithTheAttribute()
8383
.ActionAttributes(attributes => attributes.ChangingRouteTo("/api/test"));
8484
}
8585

86+
87+
[Test]
88+
public void ChangingRouteToShouldNotThrowExceptionWithActionWithTheAttributeAndCasingDifference()
89+
{
90+
MyWebApi
91+
.Controller<WebApiController>()
92+
.Calling(c => c.VariousAttributesAction())
93+
.ShouldHave()
94+
.ActionAttributes(attributes => attributes.ChangingRouteTo("/api/Test"));
95+
}
96+
8697
[Test]
8798
[ExpectedException(
8899
typeof(AttributeAssertionException),

src/MyWebApi.Tests/BuildersTests/AttributesTests/ControllerAttributesTestBuilderTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public void ChangingRouteToShouldNotThrowExceptionWithControllerWithTheAttribute
4242
.Attributes(attributes => attributes.ChangingRouteTo("/api/test"));
4343
}
4444

45+
[Test]
46+
public void ChangingRouteToShouldNotThrowExceptionWithControllerWithTheAttributeAndCaseDifference()
47+
{
48+
MyWebApi
49+
.Controller<AttributesController>()
50+
.ShouldHave()
51+
.Attributes(attributes => attributes.ChangingRouteTo("/api/Test"));
52+
}
53+
4554
[Test]
4655
[ExpectedException(
4756
typeof(AttributeAssertionException),
@@ -117,6 +126,15 @@ public void ChangingRoutePrefixToShouldNotThrowExceptionWithCorrectTheAttribute(
117126
.Attributes(attributes => attributes.ChangingRoutePrefixTo("/api/test"));
118127
}
119128

129+
[Test]
130+
public void ChangingRoutePrefixToShouldNotThrowExceptionWithCorrectTheAttributeAndCaseDifference()
131+
{
132+
MyWebApi
133+
.Controller<WebApiController>()
134+
.ShouldHave()
135+
.Attributes(attributes => attributes.ChangingRoutePrefixTo("/api/Test"));
136+
}
137+
120138
[Test]
121139
[ExpectedException(
122140
typeof(AttributeAssertionException),

src/MyWebApi/Builders/Attributes/BaseAttributesTestBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected void ChangingRouteTo(
7676
{
7777
var routeAttribute = this.TryGetAttributeOfType<RouteAttribute>(attrs);
7878
var actualTemplate = routeAttribute.Template;
79-
if (template != actualTemplate)
79+
if (template.ToLower() != actualTemplate.ToLower())
8080
{
8181
failedValidationAction(
8282
string.Format("{0} with '{1}' template", routeAttribute.GetName(), template),

src/MyWebApi/Builders/Attributes/ControllerAttributesTestBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public IAndControllerAttributesTestBuilder ChangingRoutePrefixTo(string prefix)
6969
{
7070
var routePrefixAttribute = this.GetAttributeOfType<RoutePrefixAttribute>(attrs);
7171
var actualRoutePrefix = routePrefixAttribute.Prefix;
72-
if (prefix != actualRoutePrefix)
72+
if (prefix.ToLower() != actualRoutePrefix.ToLower())
7373
{
7474
this.ThrowNewAttributeAssertionException(
7575
string.Format("{0} with '{1}' prefix", routePrefixAttribute.GetName(), prefix),

0 commit comments

Comments
 (0)