예제 #1
0
		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);
		}
예제 #2
0
		public void TestSerializeGenArrayList ()
		{
			GenArrayClass<GenListClass<string>> genarr = new GenArrayClass<GenListClass<string>> ();
			Serialize (genarr);
			Assert.AreEqual ("<:GenArrayClassOfGenListClassOfString 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'><:arr><:GenListClassOfString http://www.w3.org/2001/XMLSchema-instance:nil='true'></><:GenListClassOfString http://www.w3.org/2001/XMLSchema-instance:nil='true'></><:GenListClassOfString http://www.w3.org/2001/XMLSchema-instance:nil='true'></></></>", WriterText);

			GenListClass<string> genlist1 = new GenListClass<string> ();
			genlist1.somelist.Add ("list1-val1");
			genlist1.somelist.Add ("list1-val2");
			genarr.arr[0] = genlist1;
			GenListClass<string> genlist2 = new GenListClass<string> ();
			genlist2.somelist.Add ("list2-val1");
			genlist2.somelist.Add ("list2-val2");
			genlist2.somelist.Add ("list2-val3");
			genlist2.somelist.Add ("list2-val4");
			genarr.arr[1] = genlist2;
			GenListClass<string> genlist3 = new GenListClass<string> ();
			genlist3.somelist.Add ("list3val");
			genarr.arr[2] = genlist3;

			Serialize (genarr);
			Assert.AreEqual ("<:GenArrayClassOfGenListClassOfString 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'><:arr><:GenListClassOfString><:somelist><:string>list1-val1</><:string>list1-val2</></></><:GenListClassOfString><:somelist><:string>list2-val1</><:string>list2-val2</><:string>list2-val3</><:string>list2-val4</></></><:GenListClassOfString><:somelist><:string>list3val</></></></></>", WriterText);
		}
예제 #3
0
		public void TestSerializeGenArrayClassEnum ()
		{
			GenArrayClass<Myenum> genarr = new GenArrayClass<Myenum> ();
			Serialize (genarr);
			Assert.AreEqual (Infoset ("<GenArrayClassOfMyenum xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><arr><Myenum>one</Myenum><Myenum>one</Myenum><Myenum>one</Myenum></arr></GenArrayClassOfMyenum>"), WriterText);

			genarr.arr[0] = Myenum.one;
			genarr.arr[1] = Myenum.three;
			genarr.arr[2] = Myenum.five;

			Serialize (genarr);
			Assert.AreEqual (Infoset ("<GenArrayClassOfMyenum xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><arr><Myenum>one</Myenum><Myenum>three</Myenum><Myenum>five</Myenum></arr></GenArrayClassOfMyenum>"), WriterText);
		}
예제 #4
0
		public void TestSerializeGenArrayStruct ()
		{
			GenArrayClass<GenSimpleStruct<uint>> genarr = new GenArrayClass<GenSimpleStruct<uint>> ();
			Serialize (genarr);
			Assert.AreEqual ("<:GenArrayClassOfGenSimpleStructOfUInt32 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'><:arr><:GenSimpleStructOfUInt32><:something>0</></><:GenSimpleStructOfUInt32><:something>0</></><:GenSimpleStructOfUInt32><:something>0</></></></>", WriterText);

			GenSimpleStruct<uint> genstruct = new GenSimpleStruct<uint> ();
			genstruct.something = 111;
			genarr.arr[0] = genstruct;
			genstruct.something = 222;
			genarr.arr[1] = genstruct;
			genstruct.something = 333;
			genarr.arr[2] = genstruct;

			Serialize (genarr);
			Assert.AreEqual ("<:GenArrayClassOfGenSimpleStructOfUInt32 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'><:arr><:GenSimpleStructOfUInt32><:something>111</></><:GenSimpleStructOfUInt32><:something>222</></><:GenSimpleStructOfUInt32><:something>333</></></></>", WriterText);
		}
예제 #5
0
		public void TestSerializeGenListClassArray ()
		{
			GenListClass<GenArrayClass<char>> genlist = new GenListClass<GenArrayClass<char>> ();
			Serialize (genlist);
			Assert.AreEqual (Infoset ("<GenListClassOfGenArrayClassOfChar xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><somelist></somelist></GenListClassOfGenArrayClassOfChar>"), WriterText);

			GenArrayClass<char> genarr1 = new GenArrayClass<char> ();
			genarr1.arr[0] = 'a';
			genarr1.arr[1] = 'b';
			genlist.somelist.Add (genarr1);
			GenArrayClass<char> genarr2 = new GenArrayClass<char> ();
			genarr2.arr[0] = 'd';
			genarr2.arr[1] = 'e';
			genarr2.arr[2] = 'f';
			genlist.somelist.Add (genarr2);

			Serialize (genlist);
			Assert.AreEqual (Infoset ("<GenListClassOfGenArrayClassOfChar xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><somelist><GenArrayClassOfChar><arr><char>97</char><char>98</char><char>0</char></arr></GenArrayClassOfChar><GenArrayClassOfChar><arr><char>100</char><char>101</char><char>102</char></arr></GenArrayClassOfChar></somelist></GenListClassOfGenArrayClassOfChar>"), WriterText);
		}