public void FindsCorrectPrefixWithVirtualPath(string prefix, string template) { var resource = new PersonResource(); template = $"test/{template}"; var builder = new DefaultUrlPathBuilder(prefix, template); var url = builder.BuildCanonicalPath(resource); _output.WriteLine($"template: {template}\ngenerated result: {url}"); Assert.Equal($"{prefix.TrimEnd('/')}/test/people/", builder.BuildCanonicalPath(resource)); }
public void UseUrlPath() { var target = new DefaultUrlPathBuilder(); var result = target.BuildCanonicalPath(new PersonResource()); _output.WriteLine(result); Assert.Equal("/people/", result); }
public void AddsPrefix() { var target = new DefaultUrlPathBuilder("my-prefix"); var result = target.BuildCanonicalPath(Resource); _output.WriteLine(result); Assert.StartsWith("/my-prefix/", result); result = target.BuildCanonicalPath(Resource, Id); _output.WriteLine(result); Assert.StartsWith("/my-prefix/", result); result = target.BuildRelationshipPath(Resource, Id, Relationship); _output.WriteLine(result); Assert.StartsWith("/my-prefix/", result); result = target.BuildRelationshipPath(Resource, Id, Relationship, Id); _output.WriteLine(result); Assert.StartsWith("/my-prefix/", result); }
public void GivesCorrectResults() { var target = new DefaultUrlPathBuilder(); var result = target.BuildCanonicalPath(Resource); _output.WriteLine(result); Assert.Equal("/people/", result); result = target.BuildCanonicalPath(Resource, Id); _output.WriteLine(result); Assert.Equal("/people/123/", result); result = target.BuildRelationshipPath(Resource, Id, Relationship); _output.WriteLine(result); Assert.Equal("/people/123/relationships/job/", result); result = target.BuildRelationshipPath(Resource, Id, Relationship, Id); _output.WriteLine(result); Assert.Equal("/people/123/job/", result); }