public void Parse()
        {
            QueryStringContainer queryStringContainer = new QueryStringContainer();
            QueryStringParser    queryStringParser    = new QueryStringParser();

            NameValueCollection queryStringFields = new NameValueCollection();

            queryStringFields.Add("s", "Hey");
            queryStringFields.Add("intField", "122");
            queryStringFields.Add("iaf", "1,23,456");
            queryStringFields.Add("df", "20070408");
            queryStringFields.Add("dtf", "20070408123456");
            queryStringFields.Add("sts", "Hi,There");
            queryStringFields.Add("integers", "1,2,3,4,5");
            queryStringFields.Add("b", "1");

            queryStringParser.Parse(queryStringFields, queryStringContainer);

            Assert.AreEqual("Hey", queryStringContainer.StringField);
            Assert.AreEqual(122, queryStringContainer.IntField);
            Assert.AreEqual(new int[] { 1, 23, 456 }, queryStringContainer.IntArrayField);
            Assert.AreEqual(new DateTime(2007, 4, 8), queryStringContainer.DateField);
            Assert.AreEqual(new DateTime(2007, 4, 8, 12, 34, 56), queryStringContainer.DateTimeField);

            Assert.AreEqual("Hi", queryStringContainer.Strings[0]);
            Assert.AreEqual("There", queryStringContainer.Strings[1]);

            Assert.AreEqual(1, queryStringContainer.Ints[0]);
            Assert.AreEqual(2, queryStringContainer.Ints[1]);
            Assert.AreEqual(3, queryStringContainer.Ints[2]);
            Assert.AreEqual(4, queryStringContainer.Ints[3]);
            Assert.AreEqual(5, queryStringContainer.Ints[4]);

            Assert.IsTrue(queryStringContainer.BoolField);
        }
Beispiel #2
0
        public void Compile()
        {
            QueryStringCompiler  queryStringCompiler  = new QueryStringCompiler();
            QueryStringContainer queryStringContainer = new QueryStringContainer("Hey", 122, new int[] { 1, 23, 456 });

            string queryString = queryStringCompiler.Compile(queryStringContainer);

            Assert.AreEqual("s=Hey&intField=122&iaf=1,23,456&b=0", queryString);
        }
Beispiel #3
0
        public void Compile2()
        {
            QueryStringCompiler  queryStringCompiler  = new QueryStringCompiler();
            QueryStringContainer queryStringContainer = new QueryStringContainer("Hey", 122, new int[] { 1, 23, 456 });

            queryStringContainer.DateField     = new DateTime(2007, 4, 8);
            queryStringContainer.DateTimeField = new DateTime(2007, 4, 8, 12, 34, 56);
            queryStringContainer.Strings.Add("Hi");
            queryStringContainer.Strings.Add("There");
            queryStringContainer.BoolField = true;

            string queryString = queryStringCompiler.Compile(queryStringContainer);

            Assert.AreEqual("s=Hey&intField=122&iaf=1,23,456&df=20070408&dtf=20070408123456&sts=Hi,There&b=1", queryString);
        }