public void TestSerializeGenComplexStruct () { GenComplexStruct<int, string> complex = new GenComplexStruct<int, string> (0); Serialize (complex); Assert.AreEqual ("<:GenComplexStructOfInt32String http://www.w3.org/2000/xmlns/:xsd='http://www.w3.org/2001/XMLSchema' http://www.w3.org/2000/xmlns/:xsi='http://www.w3.org/2001/XMLSchema-instance'><:something>0</><:simpleclass><:something>0</></><:simplestruct><:something>0</></><:listclass><:somelist></></><:arrayclass><:arr><:int>0</><:int>0</><:int>0</></></><:twoclass><:something1>0</></><:derivedclass><:something2>0</><:another1>0</></><:derived2><:something1>0</><:another1>0</></><:nestedouter><:outer>0</></><:nestedinner><:something>0</></></>", WriterText); complex.something = 123; complex.simpleclass.something = 456; complex.simplestruct.something = 789; GenListClass<int> genlist = new GenListClass<int> (); genlist.somelist.Add (100); genlist.somelist.Add (200); complex.listclass = genlist; GenArrayClass<int> genarr = new GenArrayClass<int> (); genarr.arr[0] = 11; genarr.arr[1] = 22; genarr.arr[2] = 33; complex.arrayclass = genarr; complex.twoclass.something1 = 10; complex.twoclass.something2 = "Ten"; complex.derivedclass.another1 = 1; complex.derivedclass.another2 = "one"; complex.derivedclass.something1 = "two"; complex.derivedclass.something2 = 2; complex.derived2.another1 = 3; complex.derived2.another2 = "three"; complex.derived2.something1 = 4; complex.derived2.something2 = "four"; complex.nestedouter.outer = 5; complex.nestedinner.inner = "six"; complex.nestedinner.something = 6; Serialize (complex); Assert.AreEqual ("<:GenComplexStructOfInt32String http://www.w3.org/2000/xmlns/:xsd='http://www.w3.org/2001/XMLSchema' http://www.w3.org/2000/xmlns/:xsi='http://www.w3.org/2001/XMLSchema-instance'><:something>123</><:simpleclass><:something>456</></><:simplestruct><:something>789</></><:listclass><:somelist><:int>100</><:int>200</></></><:arrayclass><:arr><:int>11</><:int>22</><:int>33</></></><:twoclass><:something1>10</><:something2>Ten</></><:derivedclass><:something1>two</><:something2>2</><:another1>1</><:another2>one</></><:derived2><:something1>4</><:something2>four</><:another1>3</><:another2>three</></><:nestedouter><:outer>5</></><:nestedinner><:inner>six</><:something>6</></></>", WriterText); }
public void TestDeserializeGenComplexStruct () { Deserialize (typeof (GenComplexStruct<int, string>), "<GenComplexStructOfInt32String xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something>0</something><simpleclass><something>0</something></simpleclass><simplestruct><something>0</something></simplestruct><listclass><somelist></somelist></listclass><arrayclass><arr><int>0</int><int>0</int><int>0</int></arr></arrayclass><twoclass><something1>0</something1></twoclass><derivedclass><something2>0</something2><another1>0</another1></derivedclass><derived2><something1>0</something1><another1>0</another1></derived2><nestedouter><outer>0</outer></nestedouter><nestedinner><something>0</something></nestedinner></GenComplexStructOfInt32String>"); Assert.AreEqual (typeof (GenComplexStruct<int, string>), result.GetType ()); Deserialize (typeof (GenComplexStruct<int, string>), "<GenComplexStructOfInt32String xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something>123</something><simpleclass><something>456</something></simpleclass><simplestruct><something>789</something></simplestruct><listclass><somelist><int>100</int><int>200</int></somelist></listclass><arrayclass><arr><int>11</int><int>22</int><int>33</int></arr></arrayclass><twoclass><something1>10</something1><something2>Ten</something2></twoclass><derivedclass><something1>two</something1><something2>2</something2><another1>1</another1><another2>one</another2></derivedclass><derived2><something1>4</something1><something2>four</something2><another1>3</another1><another2>three</another2></derived2><nestedouter><outer>5</outer></nestedouter><nestedinner><inner>six</inner><something>6</something></nestedinner></GenComplexStructOfInt32String>"); GenComplexStruct<int, string> complex = new GenComplexStruct<int, string> (0); if (result != null) complex = (GenComplexStruct<int, string>) result; Assert.AreEqual (123, complex.something); Assert.AreEqual (456, complex.simpleclass.something); Assert.AreEqual (789, complex.simplestruct.something); Assert.AreEqual (100, complex.listclass.somelist[0]); Assert.AreEqual (200, complex.listclass.somelist[1]); Assert.AreEqual (11, complex.arrayclass.arr[0]); Assert.AreEqual (22, complex.arrayclass.arr[1]); Assert.AreEqual (33, complex.arrayclass.arr[2]); Assert.AreEqual (10, complex.twoclass.something1); Assert.AreEqual ("Ten", complex.twoclass.something2); Assert.AreEqual (1, complex.derivedclass.another1); Assert.AreEqual ("one", complex.derivedclass.another2); Assert.AreEqual ("two", complex.derivedclass.something1); Assert.AreEqual (2, complex.derivedclass.something2); Assert.AreEqual (3, complex.derived2.another1); Assert.AreEqual ("three", complex.derived2.another2); Assert.AreEqual (4, complex.derived2.something1); Assert.AreEqual ("four", complex.derived2.something2); Assert.AreEqual (5, complex.nestedouter.outer); Assert.AreEqual ("six", complex.nestedinner.inner); Assert.AreEqual (6, complex.nestedinner.something); }