public void TestWriteTypedPrimitive_DateTime ()
		{
			DateTime dateTime = new DateTime (1973, 08, 13);

			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", ANamespace, dateTime, false);
			// FIXME: This is a bad test case. The following switch
			// should be applied to the entire test.
#if NET_2_0
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>1973-08-13T00:00:00</x>", ANamespace),
				xsw.Content, "#1");
#else
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>{1}</x>", ANamespace, FromDateTime (dateTime)),
				xsw.Content, "#1");
#endif
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, dateTime, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x>{0}</x>", FromDateTime (dateTime)), xsw.Content, "#2");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, dateTime, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x>{0}</x>", FromDateTime (dateTime)), xsw.Content, "#3");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaNamespace, dateTime, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>{1}</x>", XmlSchemaNamespace, 
				FromDateTime (dateTime)), xsw.Content, "#4");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaInstanceNamespace, dateTime, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>{1}</x>", XmlSchemaInstanceNamespace,
				FromDateTime (dateTime)), xsw.Content, "#5");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (string.Empty, ANamespace, dateTime, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"< xmlns='{0}'>{1}</>", ANamespace, FromDateTime (dateTime)),
				xsw.Content, "#6");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (null, ANamespace, dateTime, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<dateTime xmlns='{0}'>{1}</dateTime>", XmlSchemaNamespace,
				FromDateTime (dateTime)), xsw.Content, "#7");
		}
		public void TestWriteTypedPrimitive_DateTime_XsiType ()
		{
			DateTime dateTime = new DateTime (1973, 08, 13);

			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, dateTime, true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q1='{0}' d1p1:type='q1:dateTime' xmlns:d1p1='{1}'>{2}</x>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace, 
				FromDateTime (dateTime)), xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, dateTime, true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q2='{0}' d1p1:type='q2:dateTime' xmlns:d1p1='{1}'>{2}</x>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace,
				FromDateTime (dateTime)), xsw.Content, "#2");
		}
		public void TestWriteTypedPrimitive_Char ()
		{
			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", ANamespace, 'c', false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>99</x>", ANamespace), xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, 'a', false);
			Assert.AreEqual ("<x>97</x>", xsw.Content, "#2");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, 'b', false);
			Assert.AreEqual ("<x>98</x>", xsw.Content, "#3");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaNamespace, 'd', false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>100</x>", XmlSchemaNamespace), xsw.Content, "#4");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaInstanceNamespace, 'e', false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>101</x>", XmlSchemaInstanceNamespace),
				xsw.Content, "#5");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (string.Empty, ANamespace, ' ', false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"< xmlns='{0}'>32</>", ANamespace), xsw.Content, "#6");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (null, ANamespace, '0', false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<char xmlns='{0}'>48</char>", WsdlTypesNamespace),
				xsw.Content, "#7");
		}
		public void TestWriteTypedPrimitive_Char_XsiType ()
		{
			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, 'c', true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q1='{0}' d1p1:type='q1:char' xmlns:d1p1='{1}'>99</x>",
				WsdlTypesNamespace, XmlSchemaInstanceNamespace),
				xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, 'a', true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q2='{0}' d1p1:type='q2:char' xmlns:d1p1='{1}'>97</x>",
				WsdlTypesNamespace, XmlSchemaInstanceNamespace),
				xsw.Content, "#2");
		}
		public void TestWriteTypedPrimitive_String ()
		{
			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", ANamespace, "hello", false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>hello</x>", ANamespace), xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, "hello", false);
			Assert.AreEqual ("<x>hello</x>", xsw.Content, "#2");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, "hello", false);
			Assert.AreEqual ("<x>hello</x>", xsw.Content, "#3");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaNamespace, "hello", false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>hello</x>", XmlSchemaNamespace),
				xsw.Content, "#4");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaInstanceNamespace, "hello", false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>hello</x>", XmlSchemaInstanceNamespace),
				xsw.Content, "#5");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", ANamespace, string.Empty, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}' />", ANamespace), xsw.Content, "#6");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (string.Empty, ANamespace, "<\"te'st\">", false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"< xmlns='{0}'>&lt;\"te'st\"&gt;</>", ANamespace),
				xsw.Content, "#7");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (null, ANamespace, "hello", false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<string xmlns='{0}'>hello</string>", XmlSchemaNamespace),
				xsw.Content, "#8");
		}
		public void TestWriteTypedPrimitive_Boolean_XsiType ()
		{
			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, true, true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q1='{0}' d1p1:type='q1:boolean' xmlns:d1p1='{1}'>true</x>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace),
				xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, false, true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q2='{0}' d1p1:type='q2:boolean' xmlns:d1p1='{1}'>false</x>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace),
				xsw.Content, "#2");
		}
		public void TestWriteTypedPrimitive_Base64Binary ()
		{
			byte[] byteArray = new byte[] { 255, 20, 10, 5, 0, 7 };
			string expected = "/xQKBQAH";

			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", ANamespace, byteArray, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>{1}</x>", ANamespace, expected),
				xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, byteArray, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x>{0}</x>", expected), xsw.Content, "#2");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, byteArray, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x>{0}</x>", expected), xsw.Content, "#3");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaNamespace, byteArray, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>{1}</x>", XmlSchemaNamespace, expected),
				xsw.Content, "#4");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaInstanceNamespace, byteArray, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>{1}</x>", XmlSchemaInstanceNamespace, expected),
				xsw.Content, "#5");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (string.Empty, ANamespace, byteArray, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"< xmlns='{0}'>{1}</>", ANamespace, expected), xsw.Content, "#6");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (null, ANamespace, byteArray, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<base64Binary xmlns='{0}'>{1}</base64Binary>",
				XmlSchemaNamespace, expected), xsw.Content, "#7");
		}
		public void TestWriteTypedPrimitive_Guid ()
		{
			Guid guid = new Guid ("CA761232-ED42-11CE-BACD-00AA0057B223");
			string expectedGuid = "ca761232-ed42-11ce-bacd-00aa0057b223";

			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", ANamespace, guid, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>{1}</x>", ANamespace, expectedGuid), 
				xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, guid, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x>{0}</x>", expectedGuid), xsw.Content, "#2");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, guid, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x>{0}</x>", expectedGuid), xsw.Content, "#3");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaNamespace, guid, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>{1}</x>", XmlSchemaNamespace, expectedGuid),
				xsw.Content, "#4");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaInstanceNamespace, guid, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>{1}</x>", XmlSchemaInstanceNamespace, expectedGuid),
				xsw.Content, "#5");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (string.Empty, ANamespace, guid, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"< xmlns='{0}'>{1}</>", ANamespace, expectedGuid), 
				xsw.Content, "#6");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (null, ANamespace, guid, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<guid xmlns='{0}'>{1}</guid>", WsdlTypesNamespace, 
				expectedGuid), xsw.Content, "#7");
		}
		public void TestWriteTypedPrimitive_XmlQualifiedName ()
		{
			XmlQualifiedName qname = new XmlQualifiedName ("something", AnotherNamespace);

			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", ANamespace, qname, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q1='{0}' xmlns='{1}'>q1:something</x>", 
				AnotherNamespace, ANamespace), xsw.Content, "#A1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, qname, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q2='{0}'>q2:something</x>",
				AnotherNamespace), xsw.Content, "#A2");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, qname, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q3='{0}'>q3:something</x>", AnotherNamespace), 
				xsw.Content, "#A3");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaNamespace, qname, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q4='{0}' xmlns='{1}'>q4:something</x>", AnotherNamespace, 
				XmlSchemaNamespace), xsw.Content, "#A4");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaInstanceNamespace, qname, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q5='{0}' xmlns='{1}'>q5:something</x>", AnotherNamespace, 
				XmlSchemaInstanceNamespace), xsw.Content, "#A5");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (string.Empty, ANamespace, qname, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"< xmlns:q6='{0}' xmlns='{1}'>q6:something</>", AnotherNamespace,
				ANamespace), xsw.Content, "#A6");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (null, ANamespace, qname, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<QName xmlns:q7='{0}' xmlns='{1}'>q7:something</QName>",
				AnotherNamespace, XmlSchemaNamespace), xsw.Content, "#A7");

			xsw.Reset ();

			qname = new XmlQualifiedName ("else");

			xsw.ExecuteWriteTypedPrimitive ("x", ANamespace, qname, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>else</x>", ANamespace), xsw.Content, "#B1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, qname, false);
			Assert.AreEqual ("<x>else</x>", xsw.Content, "#B2");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, qname, false);
			Assert.AreEqual ("<x>else</x>", xsw.Content, "#B3");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaNamespace, qname, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>else</x>", XmlSchemaNamespace), xsw.Content, "#B4");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaInstanceNamespace, qname, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>else</x>", XmlSchemaInstanceNamespace), 
				xsw.Content, "#B5");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (string.Empty, ANamespace, qname, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"< xmlns='{0}'>else</>", ANamespace), xsw.Content, "#B6");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (null, ANamespace, qname, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<QName xmlns='{0}'>else</QName>", XmlSchemaNamespace), 
				xsw.Content, "#B7");
		}
		public void TestWritePotentiallyReferencingElement ()
		{
			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWritePotentiallyReferencingElement ("x", ANamespace, EnumDefaultValue.e1, typeof (EnumDefaultValue), true, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>1</x>", ANamespace), xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWritePotentiallyReferencingElement ("x", ANamespace, (int) 1, typeof (EnumDefaultValue), true, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q1='{0}' d1p1:type='q1:int' xmlns:d1p1='{1}' xmlns='{2}'>1</x>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace, ANamespace),
				xsw.Content, "#2");

			xsw.Reset ();

			xsw.ExecuteWritePotentiallyReferencingElement ("x", ANamespace, "something", typeof (string), true, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>something</x>", ANamespace), xsw.Content, "#3");

			xsw.Reset ();

			xsw.ExecuteWritePotentiallyReferencingElement ("x", ANamespace, "something", null, true, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q2='{0}' d1p1:type='q2:string' xmlns:d1p1='{1}' xmlns='{2}'>something</x>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace, ANamespace),
				xsw.Content, "#4");

			xsw.Reset ();

			xsw.ExecuteWritePotentiallyReferencingElement ("x", ANamespace, new string[] { "A", "B" }, typeof (string[]), true, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<q3:Array id='id1' xmlns:q4='{0}' q3:arrayType='q4:string[2]' xmlns:q3='{1}'>" +
				"<Item>A</Item>" +
				"<Item>B</Item>" +
				"</q3:Array>", XmlSchemaNamespace, SoapEncodingNamespace), xsw.Content, "#5");
		}
		public void TestWriteTypedPrimitive_UnsignedByte_XsiType ()
		{
			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, (byte) 5, true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q1='{0}' d1p1:type='q1:unsignedByte' xmlns:d1p1='{1}'>5</x>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace),
				xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, (byte) 99, true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q2='{0}' d1p1:type='q2:unsignedByte' xmlns:d1p1='{1}'>99</x>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace),
				xsw.Content, "#2");
		}
		public void TestWriteTypedPrimitive_UnsignedByte ()
		{
			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", ANamespace, (byte) 5, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>5</x>", ANamespace), xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, (byte) 125, false);
			Assert.AreEqual ("<x>125</x>", xsw.Content, "#2");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, (byte) 0, false);
			Assert.AreEqual ("<x>0</x>", xsw.Content, "#3");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaNamespace, (byte) 255, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>255</x>", XmlSchemaNamespace), xsw.Content, "#4");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaInstanceNamespace, (byte) 128, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>128</x>", XmlSchemaInstanceNamespace),
				xsw.Content, "#5");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (string.Empty, ANamespace, (byte) 1, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"< xmlns='{0}'>1</>", ANamespace), xsw.Content, "#6");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (null, ANamespace, (byte) 99, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<unsignedByte xmlns='{0}'>99</unsignedByte>",
				XmlSchemaNamespace), xsw.Content, "#7");
		}
		public void TestWriteTypedPrimitive_String_XsiType_Namespace ()
		{
			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", ANamespace, "hello", true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q1='{0}' d1p1:type='q1:string' xmlns:d1p1='{1}' xmlns='{2}'>hello</x>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace, ANamespace),
				xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaNamespace, "hello", true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x d1p1:type='string' xmlns:d1p1='{0}' xmlns='{1}'>hello</x>",
				XmlSchemaInstanceNamespace, XmlSchemaNamespace),
				xsw.Content, "#2");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaInstanceNamespace, "hello", true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q2='{0}' d1p1:type='q2:string' xmlns:d1p1='{1}' xmlns='{1}'>hello</x>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace), xsw.Content, "#3");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", ANamespace, string.Empty, true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q3='{0}' d1p1:type='q3:string' xmlns:d1p1='{1}' xmlns='{2}' />",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace, ANamespace),
				xsw.Content, "#4");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (string.Empty, ANamespace, "<\"te'st\">", true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"< xmlns:q4='{0}' d1p1:type='q4:string' xmlns:d1p1='{1}' xmlns='{2}'>&lt;\"te'st\"&gt;</>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace, ANamespace),
				xsw.Content, "#5");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (null, ANamespace, "hello", true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<string d1p1:type='string' xmlns:d1p1='{0}' xmlns='{1}'>hello</string>",
				XmlSchemaInstanceNamespace, XmlSchemaNamespace), 
				xsw.Content, "#6");
		}
		[Category ("NotWorking")] // enum name is output instead of integral value
		public void TestWriteTypedPrimitive_Enum ()
		{
			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", ANamespace, EnumDefaultValue.e1, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>1</x>", ANamespace), xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, EnumDefaultValue.e2, false);
			Assert.AreEqual ("<x>2</x>", xsw.Content, "#2");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, EnumDefaultValue.e3, false);
			Assert.AreEqual ("<x>3</x>", xsw.Content, "#3");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaNamespace, EnumDefaultValue.e1, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>1</x>", XmlSchemaNamespace), xsw.Content, "#4");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaInstanceNamespace, EnumDefaultValue.e2, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>2</x>", XmlSchemaInstanceNamespace),
				xsw.Content, "#5");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (string.Empty, ANamespace, EnumDefaultValue.e3, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"< xmlns='{0}'>3</>", ANamespace), xsw.Content, "#6");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (null, ANamespace, EnumDefaultValue.e2, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<int xmlns='{0}'>2</int>", XmlSchemaNamespace),
				xsw.Content, "#7");
		}
		public void TestWriteTypedPrimitive_Base64Binary_XsiType ()
		{
			byte[] byteArray = new byte[] { 255, 20, 10, 5, 0, 7 };
			string expected = "/xQKBQAH";

			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, byteArray, true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q1='{0}' d1p1:type='q1:base64Binary' xmlns:d1p1='{1}'>{2}</x>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace, expected), 
				xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, byteArray, true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q2='{0}' d1p1:type='q2:base64Binary' xmlns:d1p1='{1}'>{2}</x>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace, expected),
				xsw.Content, "#2");
		}
		[Category ("NotWorking")] // InvalidOperationException is thrown
		public void TestWriteTypedPrimitive_Enum_XsiType ()
		{
			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, EnumDefaultValue.e1, true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q1='{0}' d1p1:type='q1:int' xmlns:d1p1='{1}'>1</x>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace),
				xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, EnumDefaultValue.e2, true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q2='{0}' d1p1:type='q2:int' xmlns:d1p1='{1}'>2</x>",
				XmlSchemaNamespace, XmlSchemaInstanceNamespace),
				xsw.Content, "#2");
		}
		public void TestWriteTypedPrimitive_Boolean ()
		{
			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", ANamespace, true, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>true</x>", ANamespace), xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, false, false);
			Assert.AreEqual ("<x>false</x>", xsw.Content, "#2");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, true, false);
			Assert.AreEqual ("<x>true</x>", xsw.Content, "#3");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaNamespace, false, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>false</x>", XmlSchemaNamespace), xsw.Content, "#4");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaInstanceNamespace, true, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>true</x>", XmlSchemaInstanceNamespace),
				xsw.Content, "#5");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (string.Empty, ANamespace, false, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"< xmlns='{0}'>false</>", ANamespace), xsw.Content, "#6");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (null, ANamespace, true, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<boolean xmlns='{0}'>true</boolean>", XmlSchemaNamespace),
				xsw.Content, "#7");
		}
		public void TestWriteTypedPrimitive_Guid_XsiType ()
		{
			Guid guid = new Guid ("CA761232-ED42-11CE-BACD-00AA0057B223");
			string expectedGuid = "ca761232-ed42-11ce-bacd-00aa0057b223";

			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, guid, true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q1='{0}' d1p1:type='q1:guid' xmlns:d1p1='{1}'>{2}</x>",
				WsdlTypesNamespace, XmlSchemaInstanceNamespace, expectedGuid),
				xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, guid, true);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns:q2='{0}' d1p1:type='q2:guid' xmlns:d1p1='{1}'>{2}</x>",
				WsdlTypesNamespace, XmlSchemaInstanceNamespace, expectedGuid),
				xsw.Content, "#2");
		}
		public void TestWriteTypedPrimitive_Int ()
		{
			XmlSerializarionWriterTester xsw = new XmlSerializarionWriterTester ();
			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", ANamespace, 76665, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>76665</x>", ANamespace), xsw.Content, "#1");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", string.Empty, -5656, false);
			Assert.AreEqual ("<x>-5656</x>", xsw.Content, "#2");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", null, 0, false);
			Assert.AreEqual ("<x>0</x>", xsw.Content, "#3");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaNamespace, 534, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>534</x>", XmlSchemaNamespace), xsw.Content, "#4");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive ("x", XmlSchemaInstanceNamespace, -6756, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<x xmlns='{0}'>-6756</x>", XmlSchemaInstanceNamespace),
				xsw.Content, "#5");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (string.Empty, ANamespace, 434, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"< xmlns='{0}'>434</>", ANamespace), xsw.Content, "#6");

			xsw.Reset ();

			xsw.ExecuteWriteTypedPrimitive (null, ANamespace, 434, false);
			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<int xmlns='{0}'>434</int>", XmlSchemaNamespace),
				xsw.Content, "#7");
		}