public void ReferenceResolutionNormalExamples(string expectedReferenceUrl, string userInfo, string host, string port, IEnumerable <string> path, string query, string fragment) { var uri = new RelativeReferenceBuilder().WithHost(host).WithPrefixlessPathSegments(path).WithQuery(query).WithFragment(fragment).Build(); Assert.Equal(expectedReferenceUrl, uri.ToString()); var parsed = RelativeReference.Parse(uri.ToString()); Assert.Equal(userInfo, ((IUniformResourceIdentifierReference)parsed).UserInfo); Assert.Equal(host, parsed.Host); Assert.Equal(port, parsed.Port); Assert.Equal(path, parsed.PathSegments); Assert.Equal(query, parsed.Query); Assert.Equal(fragment, parsed.Fragment); var deconstructed = new RelativeReferenceBuilder(uri).Build(); Assert.Equal(userInfo, ((IUniformResourceIdentifierReference)deconstructed).UserInfo); Assert.Equal(host, deconstructed.Host); Assert.Equal(port, deconstructed.Port); Assert.Equal(path, deconstructed.PathSegments); Assert.Equal(query, deconstructed.Query); Assert.Equal(fragment, deconstructed.Fragment); var systemUri = uri.ToUri(); Assert.False(systemUri.IsAbsoluteUri); Assert.Equal(uri.ToString(), systemUri.ToString()); }
public void ReferenceResolutionMakesPathRelativeIfNecessary() { var uri = new RelativeReferenceBuilder().WithPrefixlessPathSegments(new [] { "g:x" }).Build(); Assert.Equal("./g:x", uri.ToString()); var parsed = RelativeReference.Parse(uri.ToString()); Assert.Equal(new [] { ".", "g:x" }, parsed.PathSegments); var deconstructed = new RelativeReferenceBuilder(uri).Build(); Assert.Equal(new[] { ".", "g:x" }, deconstructed.PathSegments); var systemUri = uri.ToUri(); Assert.False(systemUri.IsAbsoluteUri); Assert.Equal(uri.ToString(), systemUri.ToString()); }