Exemple #1
0
        public void DeserializeComplexTypeWithCollection_Xml_ValidationError()
        {
            var s = new Sample_66();

            var xml = "<Person><Age>34</Age><Name>Adrian</Name><Email>[email protected]</Email><PhoneNumbers><PhoneNumber><Type>Home</Type><Number>001-2232322</Number></PhoneNumber><PhoneNumber><Type>Mobile</Type><Number>002-7787787</Number></PhoneNumber><PhoneNumber><Type>Office</Type><Number>003-4463565</Number></PhoneNumber></PhoneNumbers></Person>";

            Expect(() => Parser.Run(new[] { "foo", "-p=" + xml }, s),
                   Throws.InstanceOf<ValidationException>());
        }
Exemple #2
0
        public void DeserializeComplexTypeWithCollection_Xml()
        {
            var s = new Sample_66();

            var xml = "<Person><Age>34</Age><Name>Adrian</Name><Email>[email protected]</Email><PhoneNumbers><PhoneNumber><Type>Home</Type><Number>001-2232322</Number><SomeNumber>20</SomeNumber></PhoneNumber><PhoneNumber><Type>Mobile</Type><Number>002-7787787</Number><SomeNumber>21</SomeNumber></PhoneNumber><PhoneNumber><Type>Office</Type><Number>003-4463565</Number><SomeNumber>30</SomeNumber></PhoneNumber></PhoneNumbers></Person>";

            Parser.Run(new[] { "foo", "-p=" + xml }, s);

            Expect(s.Person.Name, Is.EqualTo("Adrian"));
            Expect(s.Person.PhoneNumbers, Count.EqualTo(3));
        }
Exemple #3
0
        public void DeserializeComplexTypeWithCollection_Json_ValidationError()
        {
            var s = new Sample_66();

            var json = "{Age: 34,Name: 'Adrian',Email: '*****@*****.**',PhoneNumbers:[{Type:'Home',Number:'001-2232322'},{Type:'Mobile',Number:'002-7787787'},{Type: 'Office',Number: '003-4463565'}]}";

            Expect(() => Parser.Run(new[] {"foo", "-p=" + json}, s),
                   Throws.InstanceOf<ValidationException>());
        }
Exemple #4
0
        public void DeserializeComplexTypeWithCollection_Json()
        {
            var s = new Sample_66();

            var json = "{Age: 34,Name: 'Adrian',Email: '*****@*****.**',PhoneNumbers:[{Type:'Home',Number:'001-2232322',SomeNumber:20},{Type:'Mobile',Number:'002-7787787',SomeNumber:21},{Type: 'Office',Number: '003-4463565',SomeNumber:30}]}";

            Parser.Run(new[] { "foo", "-p=" + json }, s);

            Expect(s.Person.Name, Is.EqualTo("Adrian"));
            Expect(s.Person.PhoneNumbers, Count.EqualTo(3));
        }
Exemple #5
0
        public void DeserializeComplexTypeWithCollection_Xml_ValidationError()
        {
            var s = new Sample_66();

            var xml = "<Person><Age>34</Age><Name>Adrian</Name><Email>[email protected]</Email><PhoneNumbers><PhoneNumber><Type>Home</Type><Number>001-2232322</Number></PhoneNumber><PhoneNumber><Type>Mobile</Type><Number>002-7787787</Number></PhoneNumber><PhoneNumber><Type>Office</Type><Number>003-4463565</Number></PhoneNumber></PhoneNumbers></Person>";

            Parser.Run(new[] { "foo", "-p=" + xml }, s);

            Assert.AreEqual("Adrian", s.Person.Name);
            Assert.AreEqual(3, s.Person.PhoneNumbers.Count);
        }
Exemple #6
0
        public void DeserializeComplexTypeWithCollection_Json_ValidationError()
        {
            var s = new Sample_66();

            var json = "{Age: 34,Name: 'Adrian',Email: '*****@*****.**',PhoneNumbers:[{Type:'Home',Number:'001-2232322'},{Type:'Mobile',Number:'002-7787787'},{Type: 'Office',Number: '003-4463565'}]}";

            Parser.Run(new[] { "foo", "-p=" + json }, s);

            Assert.AreEqual("Adrian", s.Person.Name);
            Assert.AreEqual(3, s.Person.PhoneNumbers.Count);
        }