本文整理汇总了C#中MonoTests.System.XmlSerialization.XmlSerializarionWriterTester.ExecuteWriteTypedPrimitive方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSerializarionWriterTester.ExecuteWriteTypedPrimitive方法的具体用法?C# XmlSerializarionWriterTester.ExecuteWriteTypedPrimitive怎么用?C# XmlSerializarionWriterTester.ExecuteWriteTypedPrimitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoTests.System.XmlSerialization.XmlSerializarionWriterTester
的用法示例。
在下文中一共展示了XmlSerializarionWriterTester.ExecuteWriteTypedPrimitive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestWriteTypedPrimitive_Enum_XsiType
[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");
}
示例2: TestWriteTypedPrimitive_DateTime_XsiType
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");
}
示例3: TestWriteTypedPrimitive_Enum
[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");
}
示例4: TestWriteTypedPrimitive_Char_XsiType
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");
}
示例5: TestWriteTypedPrimitive_DateTime
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");
}
示例6: TestWriteTypedPrimitive_String
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}'><\"te'st\"></>", 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");
}
示例7: TestWriteTypedPrimitive_Char
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");
}
示例8: TestWriteTypedPrimitive_Base64Binary_XsiType
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");
}
示例9: TestWriteTypedPrimitive_Boolean
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");
}
示例10: TestWriteTypedPrimitive_XmlQualifiedName
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");
}
示例11: TestWriteTypedPrimitive_Base64Binary
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");
}
示例12: TestWriteTypedPrimitive_UnsignedByte_XsiType
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");
}
示例13: TestWriteTypedPrimitive_UnsignedByte
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");
}
示例14: TestWriteTypedPrimitive_String_XsiType_Namespace
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}'><\"te'st\"></>",
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");
}
示例15: TestWriteTypedPrimitive_Guid
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");
}