Exemple #1
0
        public void TestArrayOfObjectsNullablesNull()
        {
            var service = this.GetService();

            var item = new MyItemNullables();

            var item2 = new MyItemNullables();

            var xmlArray = new XmlArray("MyItems")
                           .Add(new XmlObject("MyItem")
                                .AddNullable("MyGuid", item.MyGuid)
                                .AddNullable("MyInt", item.MyInt)
                                .AddNullable("MyDouble", item.MyDouble)
                                .AddString("MyString", item.MyString)
                                .AddNullable("MyEnumValue", item.MyEnumValue)
                                .AddNullable("MyDate", item.MyDate)
                                .AddObject("MyObj", XmlValue.CreateObject("MyObj").SetNil())
                                .AddArray("MyList", XmlValue.CreateArray("MyList").SetNil())
                                .AddArray("MyArray", XmlValue.CreateArray("MyArray").SetNil()))
                           .Add(new XmlObject("MyItem")
                                .AddNullable("MyGuid", item2.MyGuid)
                                .AddNullable("MyInt", item2.MyInt)
                                .AddNullable("MyDouble", item2.MyDouble)
                                .AddString("MyString", item2.MyString)
                                .AddNullable("MyEnumValue", item2.MyEnumValue)
                                .AddNullable("MyDate", item2.MyDate)
                                .AddObject("MyObj", XmlValue.CreateObject("MyObj").SetNil())
                                .AddArray("MyList", XmlValue.CreateArray("MyList").SetNil())
                                .AddArray("MyArray", XmlValue.CreateArray("MyArray").SetNil()));

            var result = service.GetRoot(xmlArray);

            Assert.AreEqual("<MyItems xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><MyItem><MyGuid xsi:nil=\"true\" /><MyInt xsi:nil=\"true\" /><MyDouble xsi:nil=\"true\" /><MyString xsi:nil=\"true\" /><MyEnumValue xsi:nil=\"true\" /><MyDate xsi:nil=\"true\" /><MyObj xsi:nil=\"true\" /><MyList xsi:nil=\"true\" /><MyArray xsi:nil=\"true\" /></MyItem><MyItem><MyGuid xsi:nil=\"true\" /><MyInt xsi:nil=\"true\" /><MyDouble xsi:nil=\"true\" /><MyString xsi:nil=\"true\" /><MyEnumValue xsi:nil=\"true\" /><MyDate xsi:nil=\"true\" /><MyObj xsi:nil=\"true\" /><MyList xsi:nil=\"true\" /><MyArray xsi:nil=\"true\" /></MyItem></MyItems>", result);
        }
Exemple #2
0
        public void TestObjectWithNullablesNull()
        {
            var service = this.GetService();

            var item = new MyItemNullables();

            var xmlValue = new XmlObject("MyItem")
                           .AddNullable <Guid?>("MyGuid", null)
                           .AddNullable <int?>("MyInt", null)
                           .AddNullable <double?>("MyDouble", null)
                           .AddString("MyString", null)
                           .AddNullable <MyEnum?>("MyEnumValue", null)
                           .AddNullable <DateTime?>("MyDate", null)
                           .AddObject("MyObj", XmlValue.CreateObject("MyObj").SetNil())
                           .AddArray("MyList", XmlValue.CreateArray("MyList").SetNil())
                           .AddArray("MyArray", XmlValue.CreateArray("MyArray").SetNil());

            var result = service.GetRoot(xmlValue);

            Assert.AreEqual("<MyItem xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><MyGuid xsi:nil=\"true\" /><MyInt xsi:nil=\"true\" /><MyDouble xsi:nil=\"true\" /><MyString xsi:nil=\"true\" /><MyEnumValue xsi:nil=\"true\" /><MyDate xsi:nil=\"true\" /><MyObj xsi:nil=\"true\" /><MyList xsi:nil=\"true\" /><MyArray xsi:nil=\"true\" /></MyItem>", result);
        }
Exemple #3
0
        public void TestObjectWithNullables()
        {
            var service = this.GetService();

            var item = new MyItemNullables
            {
                MyGuid      = new Guid("11ba7957-5afb-4b59-9d9b-c06a18cda5c2"),
                MyInt       = 1,
                MyDouble    = 1.5,
                MyString    = "my value",
                MyBool      = true,
                MyEnumValue = MyEnum.Other,
                MyDate      = new DateTime(1990, 12, 12),
                MyObj       = new MyInnerItem {
                    MyInnerString = "my inner value"
                },
                MyList = new List <string> {
                    "a", "b"
                },
                MyArray = new string[] { "y", "z" }
            };

            var xmlValue = new XmlObject("MyItem")
                           .AddNullable("MyGuid", item.MyGuid)
                           .AddNullable("MyInt", item.MyInt)
                           .AddNullable("MyDouble", item.MyDouble)
                           .AddString("MyString", item.MyString)
                           .AddNullable("MyEnumValue", item.MyEnumValue)
                           .AddNullable("MyDate", item.MyDate)
                           .AddObject("MyObj", XmlValue.CreateObject("MyObj").AddString("MyInnerString", "my inner value"))
                           .AddArray("MyList", XmlValue.CreateArray("MyList").Add(new XmlString("String", "a")).Add(new XmlString("String", "b")))
                           .AddArray("MyArray", XmlValue.CreateArray("MyArray").Add(new XmlString("String", "y")).Add(new XmlString("String", "z")));

            var result = service.GetRoot(xmlValue);

            Assert.AreEqual("<MyItem><MyGuid>11ba7957-5afb-4b59-9d9b-c06a18cda5c2</MyGuid><MyInt>1</MyInt><MyDouble>1.5</MyDouble><MyString>my value</MyString><MyEnumValue>Other</MyEnumValue><MyDate>12/12/1990 00:00:00</MyDate><MyObj><MyInnerString>my inner value</MyInnerString></MyObj><MyList><String>a</String><String>b</String></MyList><MyArray><String>y</String><String>z</String></MyArray></MyItem>", result);
        }
Exemple #4
0
        public void TestArrayOfObjectsNullables()
        {
            var service = this.GetService();

            var item = new MyItemNullables
            {
                MyGuid      = new Guid("11ba7957-5afb-4b59-9d9b-c06a18cda5c2"),
                MyInt       = 1,
                MyDouble    = 1.5,
                MyString    = "my value 1",
                MyBool      = true,
                MyEnumValue = MyEnum.Other,
                MyDate      = new DateTime(1990, 12, 12),
                MyObj       = new MyInnerItem {
                    MyInnerString = "my inner value 1"
                },
                MyList = new List <string> {
                    "a1", "b1"
                },
                MyArray = new string[] { "y1", "z1" }
            };

            var item2 = new MyItemNullables
            {
                MyGuid      = new Guid("11ba7957-5afb-4b59-9d9b-c06a18cda5c3"),
                MyInt       = 2,
                MyDouble    = 2.5,
                MyString    = "my value 2",
                MyBool      = false,
                MyEnumValue = MyEnum.Default,
                MyDate      = new DateTime(1990, 10, 12),
                MyObj       = new MyInnerItem {
                    MyInnerString = "my inner value 2"
                },
                MyList = new List <string> {
                    "a2", "b2"
                },
                MyArray = new string[] { "y2", "z2" }
            };

            var xmlArray = new XmlArray("MyItems")
                           .Add(new XmlObject("MyItem")
                                .AddNullable("MyGuid", item.MyGuid)
                                .AddNullable("MyInt", item.MyInt)
                                .AddNullable("MyDouble", item.MyDouble)
                                .AddString("MyString", item.MyString)
                                .AddNullable("MyEnumValue", item.MyEnumValue)
                                .AddNullable("MyDate", item.MyDate)
                                .AddObject("MyObj", XmlValue.CreateObject("MyObj").AddString("MyInnerString", "my inner value 1"))
                                .AddArray("MyList", XmlValue.CreateArray("MyList").Add(new XmlString("String", item.MyList[0])).Add(new XmlString("String", item.MyList[1])))
                                .AddArray("MyArray", XmlValue.CreateArray("MyArray").Add(new XmlString("String", item.MyArray[0])).Add(new XmlString("String", item.MyArray[1]))))
                           .Add(new XmlObject("MyItem")
                                .AddNullable("MyGuid", item2.MyGuid)
                                .AddNullable("MyInt", item2.MyInt)
                                .AddNullable("MyDouble", item2.MyDouble)
                                .AddString("MyString", item2.MyString)
                                .AddNullable("MyEnumValue", item2.MyEnumValue)
                                .AddNullable("MyDate", item2.MyDate)
                                .AddObject("MyObj", XmlValue.CreateObject("MyObj").AddString("MyInnerString", "my inner value 2"))
                                .AddArray("MyList", XmlValue.CreateArray("MyList").Add(new XmlString("String", item2.MyList[0])).Add(new XmlString("String", item2.MyList[0])))
                                .AddArray("MyArray", XmlValue.CreateArray("MyArray").Add(new XmlString("String", item2.MyArray[0])).Add(new XmlString("String", item2.MyArray[1]))));

            var result = service.GetRoot(xmlArray);

            Assert.AreEqual("<MyItems><MyItem><MyGuid>11ba7957-5afb-4b59-9d9b-c06a18cda5c2</MyGuid><MyInt>1</MyInt><MyDouble>1.5</MyDouble><MyString>my value 1</MyString><MyEnumValue>Other</MyEnumValue><MyDate>12/12/1990 00:00:00</MyDate><MyObj><MyInnerString>my inner value 1</MyInnerString></MyObj><MyList><String>a1</String><String>b1</String></MyList><MyArray><String>y1</String><String>z1</String></MyArray></MyItem><MyItem><MyGuid>11ba7957-5afb-4b59-9d9b-c06a18cda5c3</MyGuid><MyInt>2</MyInt><MyDouble>2.5</MyDouble><MyString>my value 2</MyString><MyEnumValue>Default</MyEnumValue><MyDate>12/10/1990 00:00:00</MyDate><MyObj><MyInnerString>my inner value 2</MyInnerString></MyObj><MyList><String>a2</String><String>a2</String></MyList><MyArray><String>y2</String><String>z2</String></MyArray></MyItem></MyItems>", result);
        }