public void EncodesFragmentArguments()
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.AppendFragment("foo/{0}", "bar#bar");

            Assert.Equal("#/foo/bar%23bar", builder.ToUri().Fragment);
        }
        public void DoesNotEncodeThePathSeperator()
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.AppendFragment("foo/bar");

            Assert.Equal("#/foo/bar", builder.ToUri().Fragment);
        }
        public void EncodesFragment(string path, string expectedPath)
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.AppendFragment(path);

            Assert.Equal(expectedPath, builder.ToUri().Fragment);
        }
        public void WhenNoExistingFragment_SetsFragment(string url)
        {
            var builder = new HttpUrlBuilder(url);

            builder.AppendFragment("foo/bar");

            Assert.Equal("#/foo/bar", builder.ToUri().Fragment);
        }
        public void AppendsFragmentToExisting(string url)
        {
            var builder = new HttpUrlBuilder(url);

            builder.AppendFragment("foo/bar");

            Assert.Equal("#/existing/path/foo/bar", builder.ToUri().Fragment);
        }
        public void FormatsFragment()
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.AppendFragment("foo/{0}", "bar");

            Assert.Equal("#/foo/bar", builder.ToUri().Fragment);
        }
        public void DoesNotEncodeThePathSeperator()
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.WithPath("foo/bar");

            Assert.Equal("/foo/bar", builder.ToUri().AbsolutePath);
        }
        public void EncodesName()
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.AddQuery("na/me", "value");

            Assert.Equal("?na%2Fme=value", builder.ToUri().Query);
        }
        public void AppendsPathToExisting(string url)
        {
            var builder = new HttpUrlBuilder(url);

            builder.AppendPath("foo/bar");

            Assert.Equal("/existing/path/foo/bar", builder.ToUri().AbsolutePath);
        }
        public void WhenInitialUrlHasQueryString_AppendsQueryToExisting()
        {
            var builder = new HttpUrlBuilder("http://localhost?name1=value1");

            builder.AddQuery("name2", "value2");

            Assert.Equal("?name1=value1&name2=value2", builder.ToUri().Query);
        }
        public void AddsValueToUrl()
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.AddQuery("name", "value");

            Assert.Equal("?name=value", builder.ToUri().Query);
        }
        public void FormatsPath()
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.WithPath("foo/{0}", "bar");

            Assert.Equal("/foo/bar", builder.ToUri().AbsolutePath);
        }
        public void WhenNoExistingPath_SetsAbsolutePath(string url)
        {
            var builder = new HttpUrlBuilder(url);

            builder.AppendPath("foo/bar");

            Assert.Equal("/foo/bar", builder.ToUri().AbsolutePath);
        }
        public void EncodesPathArguments()
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.WithPath("foo/{0}", "bar#bar");

            Assert.Equal("/foo/bar%23bar", builder.ToUri().AbsolutePath);
        }
        public void EncodesPath(string path, string expectedPath)
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.WithPath(path);

            Assert.Equal(expectedPath, builder.ToUri().AbsolutePath);
        }
        public void OverwritesExistingPath(string url)
        {
            var builder = new HttpUrlBuilder(url);

            builder.WithPath("foo/bar");

            Assert.Equal("/foo/bar", builder.ToUri().AbsolutePath);
        }
        public void AddsMultipleValuesWithSameNameToUrl()
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.AddQuery("name", "value1");
            builder.AddQuery("name", "value2");

            Assert.Equal("?name=value1&name=value2", builder.ToUri().Query);
        }
        public void InitializesUrlFromString()
        {
            var builder = new HttpUrlBuilder("http://localhost/api/foo");

            Assert.Equal(new Uri("http://localhost/api/foo"), builder.ToUri());
        }
        public void InitializesUrlFromComponents()
        {
            var builder = new HttpUrlBuilder("localhost", port: 1234, scheme: "https");

            Assert.Equal(new Uri("https://localhost:1234"), builder.ToUri());
        }
        public void ConvertsAbsoluteToUri()
        {
            var builder = new HttpUrlBuilder("http://localhost/api/foo", UriKind.Absolute);

            Assert.Equal(new Uri("http://localhost/api/foo", UriKind.Absolute), builder.ToUri());
        }
        public void ConvertsRelativeToUri()
        {
            var builder = new HttpUrlBuilder("/api/foo", UriKind.Relative);

            Assert.Equal(new Uri("/api/foo", UriKind.Relative), builder.ToUri());
        }
        public void ConvertsToUri()
        {
            var builder = new HttpUrlBuilder("http://localhost/api/foo");

            Assert.Equal(new Uri("http://localhost/api/foo"), builder.ToUri());
        }
        public void InitializesUrlFromRelativeUri()
        {
            var builder = new HttpUrlBuilder(new Uri("/api/foo", UriKind.Relative));

            Assert.Equal(new Uri("/api/foo", UriKind.Relative), builder.ToUri());
        }
        public void InitializesUrlFromAbsoluteUri()
        {
            var builder = new HttpUrlBuilder(new Uri("http://localhost/api/foo", UriKind.Absolute));

            Assert.Equal(new Uri("http://localhost/api/foo", UriKind.Absolute), builder.ToUri());
        }