[Test] // ctor (Byte []) public void Constructor2() { byte [] bytes; SoapHexBinary shb; bytes = new byte [] { 2, 3, 5, 7, 11 }; shb = new SoapHexBinary(bytes); Assert.AreEqual("hexBinary", shb.GetXsdType(), "#A1"); Assert.AreEqual("020305070B", shb.ToString(), "#A2"); Assert.AreSame(bytes, shb.Value, "#A3"); bytes = new byte [0]; shb = new SoapHexBinary(bytes); Assert.AreEqual("hexBinary", shb.GetXsdType(), "#B1"); Assert.AreEqual("", shb.ToString(), "#B2"); Assert.AreSame(bytes, shb.Value, "#B3"); bytes = null; shb = new SoapHexBinary(bytes); Assert.AreEqual("hexBinary", shb.GetXsdType(), "#C1"); try { shb.ToString(); Assert.Fail("#C2"); } catch (NullReferenceException) { } Assert.IsNull(shb.Value, "#C3"); }
public static void Main(string[] args) { // Parse an XSD formatted string to create a SoapHexBinary object. string xsdHexBinary = "3f789ABC"; SoapHexBinary hexBinary = SoapHexBinary.Parse(xsdHexBinary); // Print the value of the SoapHexBinary object in XSD format. Console.WriteLine("The SoapHexBinary object in XSD format is {0}.", hexBinary.ToString()); // Print the XSD type string of this particular SoapHexBinary object. Console.WriteLine( "The XSD type of the SoapHexBinary object is {0}.", hexBinary.GetXsdType()); // Print the value of the SoapHexBinary object. Console.Write("hexBinary.Value contains:"); for (int i = 0; i < hexBinary.Value.Length; ++i) { Console.Write(" " + hexBinary.Value[i]); } Console.WriteLine(); // Print the XSD type string of the SoapHexBinary class. Console.WriteLine("The XSD type of the class SoapHexBinary is {0}.", SoapHexBinary.XsdType); }
[Test] // ctor () public void Constructor1() { SoapHexBinary shb = new SoapHexBinary(); Assert.AreEqual("hexBinary", shb.GetXsdType(), "#1"); try { shb.ToString(); Assert.Fail("#2"); } catch (NullReferenceException) { } Assert.IsNull(shb.Value, "#3"); }