Exemple #1
0
        public void Deos_serialize_QueryStrings()
        {
            var testPocos = new TestPocos {
                ListOfA = new List <A> {
                    new A {
                        ListOfB = new List <B> {
                            new B {
                                Property = "prop1"
                            }, new B {
                                Property = "prop2"
                            }
                        }
                    }
                }
            };

            Assert.That(QueryStringSerializer.SerializeToString(testPocos), Is.EqualTo(
                            "ListOfA={ListOfB:[{Property:prop1},{Property:prop2}]}"));

            Assert.That(QueryStringSerializer.SerializeToString(new[] { 1, 2, 3 }), Is.EqualTo(
                            "[1,2,3]"));

            Assert.That(QueryStringSerializer.SerializeToString(new[] { "AA", "BB", "CC" }), Is.EqualTo(
                            "[AA,BB,CC]"));
        }
 public void Can_serialize_with_comma_in_property_in_list()
 {
     var testPocos = new TestPocos
         {
             ListOfA = new List<A> { new A { ListOfB = new List<B> { new B { Property = "Doe, John", Property2 = "Doe", Property3 = "John" } } } }
         };
     Assert.That(QueryStringSerializer.SerializeToString(testPocos), Is.EqualTo("ListOfA={ListOfB:[{Property:%22Doe,+John%22,Property2:Doe,Property3:John}]}"));
 }
 public void Can_deserialize_with_comma_in_property_in_list_from_QueryStringSerializer()
 {
     var testPocos = new TestPocos
     {
         ListOfA = new List<A> { new A { ListOfB = new List<B> { new B { Property = "Doe, John", Property2 = "Doe", Property3 = "John" } } } }
     };
     var str = QueryStringSerializer.SerializeToString(testPocos);
     var poco = StringToPoco<TestPocos>(str);
     Assert.That(poco.ListOfA[0].ListOfB[0].Property, Is.EqualTo("Doe, John"));
     Assert.That(poco.ListOfA[0].ListOfB[0].Property2, Is.EqualTo("Doe"));
     Assert.That(poco.ListOfA[0].ListOfB[0].Property3, Is.EqualTo("John"));
 }