Esempio n. 1
0
        public void ParseQueryString_Null_Should_Ok()
        {
            var simpleQueryString = new SimpleQueryString();
            var nvc = simpleQueryString.ParseQueryString(null);

            nvc.Count.ShouldEqual(0);
        }
Esempio n. 2
0
        public void CreateQueryString_Null_NotAutoAppend_Should_Ok()
        {
            var simpleQueryString = new SimpleQueryString();
            var queryString       = simpleQueryString.CreateQueryString(null, false);

            queryString.ShouldEqual(string.Empty);
        }
Esempio n. 3
0
        public void CreateQueryStringFromObject_MultiValues_Should_Ok()
        {
            var simpleQueryString = new SimpleQueryString();
            var myObj             = new MyObjectWithMultiValues();

            simpleQueryString.CreateQueryStringFromObject(myObj, false).ShouldEqual("A=1,2&B=2&B=3&C=4&C=5");
            simpleQueryString.CreateQueryStringFromObject(myObj, false, new [] { "a", "B" }).ShouldEqual("A=1,2&B=2&B=3");
        }
Esempio n. 4
0
        public void ParseQueryStringToDic_Should_Ok()
        {
            var simpleQueryString = new SimpleQueryString();
            var dic = simpleQueryString.ParseQueryStringToDic("a=1&b=2&b=3");

            dic.Count.ShouldEqual(2);
            dic["A"].ShouldEqual("1");
            dic["B"].ShouldEqual("2,3");
        }
Esempio n. 5
0
        public void ParseQueryString_EmptyValue_Should_Ok()
        {
            var simpleQueryString = new SimpleQueryString();
            var nvc = simpleQueryString.ParseQueryString("a=1&b=");

            nvc.Count.ShouldEqual(2);
            nvc["A"].ShouldEqual("1");
            nvc["B"].ShouldEqual(string.Empty);
        }
Esempio n. 6
0
        public void CreateQueryString_EmptyValue_Should_Ok()
        {
            var simpleQueryString = new SimpleQueryString();
            var nvc = new NameValueCollection();

            nvc.Add("a", "1");
            nvc.Add("b", "");
            var queryString = simpleQueryString.CreateQueryString(nvc, false);

            queryString.ShouldEqual("a=1&b=");
        }
Esempio n. 7
0
        public void CreateQueryStringFromObject_Should_Ok()
        {
            var simpleQueryString = new SimpleQueryString();
            var myObj             = new MyObject();

            myObj.A = "1";
            myObj.B = 2;
            var queryString = simpleQueryString.CreateQueryStringFromObject(myObj, false);

            queryString.ShouldEqual("A=1&B=2");
        }
Esempio n. 8
0
        public void CreateQueryStringFromDic_Should_Ok()
        {
            var simpleQueryString = new SimpleQueryString();
            var dic = new Dictionary <string, string>();

            dic.Add("a", "1");
            dic.Add("b", "2");
            var queryString = simpleQueryString.CreateQueryStringFromDic(dic, false);

            queryString.ShouldEqual("a=1&b=2");
        }
Esempio n. 9
0
        public void ParseQueryString_RepeatKey_Should_Ok()
        {
            var simpleQueryString = new SimpleQueryString();
            var nvc = simpleQueryString.ParseQueryString("a=1&b=2&b=3");

            nvc.Count.ShouldEqual(2);
            nvc["A"].ShouldEqual("1");
            nvc["B"].ShouldEqual("2,3");
            var values = nvc.GetValues("b");

            values.Length.ShouldEqual(2);
            values[0].ShouldEqual("2");
            values[1].ShouldEqual("3");
        }