public void TestUnmarshalPrimitiveMap() { XmlPrimitiveMapMarshaler marshaler = new XmlPrimitiveMapMarshaler(); byte[] rawBytes = Encoding.UTF8.GetBytes(xmlString); IPrimitiveMap result = marshaler.Unmarshal(rawBytes); Assert.IsNotNull(result); Assert.IsTrue(result.Contains("BOOL")); Assert.IsTrue(result.Contains("BYTES")); Assert.IsTrue(result.Contains("STRING")); Assert.IsTrue(result.Contains("LONG")); Assert.IsTrue(result.Contains("FLOAT")); Assert.IsTrue(result.Contains("INT")); Assert.IsTrue(result.Contains("BYTE")); Assert.IsTrue(result.Contains("SHORT")); Assert.IsTrue(result.Contains("DOUBLE")); Assert.IsTrue(result.Contains("CHAR")); }
public void TestMarshalPrimitiveMap() { XmlPrimitiveMapMarshaler marshaler = new XmlPrimitiveMapMarshaler(); PrimitiveMap map = new PrimitiveMap(); map.SetBool("boolean", true); map.SetByte("byte", (byte)1); map["bytes1"] = new byte[1]; map.SetChar("char", 'a'); map.SetDouble("double", 1.5); map.SetFloat("float", 1.5f); map.SetInt("int", 1); map.SetLong("long", 1); map["object"] = "stringObj"; map.SetShort("short", (short)1); map.SetString("string", "string"); byte[] result = marshaler.Marshal(map); Assert.IsNotNull(result); result = marshaler.Marshal(null); Assert.IsNull(result); }