Пример #1
0
        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));
        }
Пример #2
0
        public void UseUrlPath()
        {
            var target = new DefaultUrlPathBuilder();
            var result = target.BuildCanonicalPath(new PersonResource());

            _output.WriteLine(result);

            Assert.Equal("/people/", result);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }