public void UriNoPath()
        {
            var uri = new Uri("http://localhost:8080?param1=value1&param2=value2&param3=value3");
            var d   = new QueryStringDecoder(uri);

            // The path component cannot be empty string,
            // if there are no path component, it shoudl be '/' as above UriSlashPath test
            Assert.Equal("/", d.Path);
            Assert.Equal("/", d.RawPath());
            Assert.Equal("param1=value1&param2=value2&param3=value3", d.RawQuery());

            IDictionary <string, List <string> > parameters = d.Parameters;

            Assert.Equal(3, parameters.Count);

            KeyValuePair <string, List <string> > entry = parameters.ElementAt(0);

            Assert.Equal("param1", entry.Key);
            Assert.Single(entry.Value);
            Assert.Equal("value1", entry.Value[0]);

            entry = parameters.ElementAt(1);
            Assert.Equal("param2", entry.Key);
            Assert.Single(entry.Value);
            Assert.Equal("value2", entry.Value[0]);

            entry = parameters.ElementAt(2);
            Assert.Equal("param3", entry.Key);
            Assert.Single(entry.Value);
            Assert.Equal("value3", entry.Value[0]);
        }
        public void UriSlashPath()
        {
            var uri = new Uri("http://localhost:8080/?param1=value1&param2=value2&param3=value3");
            var d   = new QueryStringDecoder(uri);

            Assert.Equal("/", d.Path);
            Assert.Equal("/", d.RawPath());
            Assert.Equal("param1=value1&param2=value2&param3=value3", d.RawQuery());

            IDictionary <string, List <string> > parameters = d.Parameters;

            Assert.Equal(3, parameters.Count);

            KeyValuePair <string, List <string> > entry = parameters.ElementAt(0);

            Assert.Equal("param1", entry.Key);
            Assert.Single(entry.Value);
            Assert.Equal("value1", entry.Value[0]);

            entry = parameters.ElementAt(1);
            Assert.Equal("param2", entry.Key);
            Assert.Single(entry.Value);
            Assert.Equal("value2", entry.Value[0]);

            entry = parameters.ElementAt(2);
            Assert.Equal("param3", entry.Key);
            Assert.Single(entry.Value);
            Assert.Equal("value3", entry.Value[0]);
        }
        public void EmptyStrings()
        {
            var pathSlash = new QueryStringDecoder("path/");

            Assert.Equal("path/", pathSlash.RawPath());
            Assert.Equal("", pathSlash.RawQuery());
            var pathQuestion = new QueryStringDecoder("path?");

            Assert.Equal("path", pathQuestion.RawPath());
            Assert.Equal("", pathQuestion.RawQuery());
            var empty = new QueryStringDecoder("");

            Assert.Equal("", empty.RawPath());
            Assert.Equal("", empty.RawQuery());
        }
        public void Uri2()
        {
            var uri = new Uri("http://foo.com/images;num=10?query=name;value=123");
            var d   = new QueryStringDecoder(uri);

            Assert.Equal("/images;num=10", d.Path);
            Assert.Equal("/images;num=10", d.RawPath());
            Assert.Equal("query=name;value=123", d.RawQuery());

            IDictionary <string, List <string> > parameters = d.Parameters;

            Assert.Equal(2, parameters.Count);

            KeyValuePair <string, List <string> > entry = parameters.ElementAt(0);

            Assert.Equal("query", entry.Key);
            Assert.Single(entry.Value);
            Assert.Equal("name", entry.Value[0]);

            entry = parameters.ElementAt(1);
            Assert.Equal("value", entry.Key);
            Assert.Single(entry.Value);
            Assert.Equal("123", entry.Value[0]);
        }