Created
March 6, 2013 10:03
-
-
Save starteleport/5098244 to your computer and use it in GitHub Desktop.
Ambiguous UrlExtensions.ToUrl method behaviour
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Route("/route/{Id}")] | |
public class JustId : IReturn | |
{ | |
public long Id { get; set; } | |
} | |
[Route("route/{Id}")] | |
public class JustId_NoSlash : IReturn | |
{ | |
public long Id { get; set; } | |
} | |
[TestFixture] | |
public class UrlExtensionTests | |
{ | |
[Test] | |
public void Starting_slash_test_Fails() | |
{ | |
var serviceEndpoint = new Uri("http://localhost/api/", UriKind.Absolute); | |
var actionUrl = new Uri(new JustId { Id = 1 }.ToUrl("GET"), UriKind.Relative); | |
Assert.That(new Uri(serviceEndpoint, actionUrl).ToString(), Is.EqualTo("http://localhost/api/route/1")); | |
} | |
[Test] | |
public void Starting_slash_test_Passes() | |
{ | |
var serviceEndpoint = new Uri("http://localhost/api/", UriKind.Absolute); | |
var actionUrl = new Uri(new JustId_NoSlash { Id = 1 }.ToUrl("GET"), UriKind.Relative); | |
Assert.That(new Uri(serviceEndpoint, actionUrl).ToString(), Is.EqualTo("http://localhost/api/route/1")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment