示例#1
0
        public void CreateURLObjectArray()
        {
            var url = UrlUtils.CreateUrl("http://test.com", new {
                key1 = new[] { "value1", "value2" },
            });

            Assert.Equal("http://test.com/?key1[]=value1&key1[]=value2", url);
        }
示例#2
0
        public void CreateURLObject()
        {
            var url = UrlUtils.CreateUrl("http://test.com", new {
                key1 = "value1",
            });

            Assert.Equal("http://test.com/?key1=value1", url);
        }
示例#3
0
        public void CreateURLKeyValuePairList()
        {
            var url = UrlUtils.CreateUrl("http://test.com", new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>("key1", "value1")
            });

            Assert.Equal("http://test.com/?key1=value1", url);
        }
示例#4
0
        public void CreateURLEscape()
        {
            var url = UrlUtils.CreateUrl("http://test.com", new Dictionary <string, string>()
            {
                ["key1"] = "value1 value2",
            });

            Assert.Equal("http://test.com/?key1=value1%20value2", url);
        }
示例#5
0
        public void CreateURLDictionaryHttps()
        {
            var url = UrlUtils.CreateUrl("https://test.com", new Dictionary <string, string>()
            {
                ["key1"] = "value1",
            });

            Assert.Equal("https://test.com/?key1=value1", url);
        }
示例#6
0
        public void CreateURLKeyValuePairListMultipleArray()
        {
            var url = UrlUtils.CreateUrl("http://test.com", new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>("key1[]", "value1"),
                new KeyValuePair <string, string>("key1[]", "value2"),
            });

            Assert.Equal("http://test.com/?key1[]=value1&key1[]=value2", url);
        }
示例#7
0
        public void ExtendUrlEscape()
        {
            var url = UrlUtils.CreateUrl("http://test.com", new Dictionary <string, string>()
            {
                ["key1"] = "value1 value2",
            });

            Assert.Equal("http://test.com/?key1=value1%20value2", url);

            url = UrlUtils.ExtendUrl(url, new Dictionary <string, string> {
                ["key2"] = "value2"
            });

            Assert.Equal("http://test.com/?key1=value1%20value2&key2=value2", url);

            url = UrlUtils.ExtendUrl(url, new Dictionary <string, string> {
                ["key1"] = "value1",
                ["key3"] = "value3",
            });

            Assert.Equal("http://test.com/?key1=value1&key2=value2&key3=value3", url);
        }
示例#8
0
        public void CreateURLEmpty()
        {
            var url = UrlUtils.CreateUrl("http://test.com", (Dictionary <string, string>)null);

            Assert.Equal("http://test.com", url);
        }