예제 #1
0
        public void OneParameterIsRead()
        {
            var qs = QueryString.FromUrl("http://example.com?name=value");

            Assert.IsTrue(qs.Contains("name"));
            Assert.AreEqual("value", qs["name"]);
        }
예제 #2
0
        public void ThreeParametersAreReadFromString()
        {
            var qs = QueryString.FromUrl("http://example.com?name1=value1&name2=value2&name3=value3");

            Assert.IsTrue(qs.Contains("name1"));
            Assert.AreEqual("value1", qs["name1"]);
            Assert.IsTrue(qs.Contains("name2"));
            Assert.AreEqual("value2", qs["name2"]);
            Assert.IsTrue(qs.Contains("name3"));
            Assert.AreEqual("value3", qs["name3"]);
        }
예제 #3
0
        public void DifferentUriTypesAreFine()
        {
            QueryString.FromUrl(new Uri("http://example.com?a=b", UriKind.Absolute));
            QueryString.FromUrl(new Uri("index.html?a=b", UriKind.Relative));
            QueryString.FromUrl(new Uri("index.html?a=b", UriKind.RelativeOrAbsolute));

            // We also check all of them without the QS part.
            QueryString.FromUrl(new Uri("http://example.com", UriKind.Absolute));
            QueryString.FromUrl(new Uri("index.html", UriKind.Relative));
            QueryString.FromUrl(new Uri("index.html", UriKind.RelativeOrAbsolute));
        }
예제 #4
0
        public void ThreeParametersAreReadFromUri()
        {
            // Same as ThreeParametersAreReadFromString but using Uri as input (to ensure parsing works for all sources)
            var qs = QueryString.FromUrl(new Uri("http://example.com?name1=value1&name2=value2&name3=value3"));

            Assert.IsTrue(qs.Contains("name1"));
            Assert.AreEqual("value1", qs["name1"]);
            Assert.IsTrue(qs.Contains("name2"));
            Assert.AreEqual("value2", qs["name2"]);
            Assert.IsTrue(qs.Contains("name3"));
            Assert.AreEqual("value3", qs["name3"]);
        }
예제 #5
0
        public void EmptyInEmptyOut()
        {
            var qs = QueryString.FromUrl("http://example.com/index");

            Assert.AreEqual("?", qs.ToString());
        }
예제 #6
0
 public void EmptyStringIsFineAsUrl()
 {
     QueryString.FromUrl("");
 }
예제 #7
0
 public void StringUrlWithoutQueryStringIsFine()
 {
     QueryString.FromUrl("page.html");
 }