public void TestMethodEnumSerialization() { JsonObjectSerializer serializer = new JsonObjectSerializer(); EnumTestObject testObject = new EnumTestObject(); testObject.Type = IOCTalk.Common.Interface.Communication.MessageType.MethodInvokeRequest; string json = serializer.Serialize(testObject, null); EnumTestObject deserializedObj = (EnumTestObject)serializer.Deserialize(json, typeof(EnumTestObject), null); Assert.Equal <MessageType>(testObject.Type, deserializedObj.Type); }
public void TestMethodEnumSerialization() { BinarySerializer serializer = new BinarySerializer(new UnknowTestTypeResolver()); EnumTestObject testObject = new EnumTestObject(); testObject.Type = IOCTalk.Common.Interface.Communication.MessageType.MethodInvokeRequest; testObject.InObjectEnum = TypeCode.Int16; var data = serializer.Serialize(testObject, null); BinarySerializer.ClearGlobalStructureCache(); EnumTestObject deserializedObj = (EnumTestObject)serializer.Deserialize(data, null); Assert.Equal <MessageType>(testObject.Type, deserializedObj.Type); Assert.Equal <TypeCode>((TypeCode)testObject.InObjectEnum, (TypeCode)deserializedObj.InObjectEnum); }
public void TestMethodMessageSerialization() { BinarySerializer serializer = new BinarySerializer(new UnknowTestTypeResolver()); EnumTestObject testObject = new EnumTestObject(); testObject.Type = IOCTalk.Common.Interface.Communication.MessageType.MethodInvokeRequest; testObject.InObjectEnum = TypeCode.Double; GenericMessage msg = new GenericMessage(1, testObject); var data = serializer.Serialize(msg, null); BinarySerializer.ClearGlobalStructureCache(); GenericMessage deserializedMsg = (GenericMessage)serializer.Deserialize(data, null); Assert.Equal <MessageType>(msg.Type, deserializedMsg.Type); Assert.Equal(((EnumTestObject)msg.Payload).InObjectEnum, ((EnumTestObject)deserializedMsg.Payload).InObjectEnum); }
public void SetEnumProperty() { EnumTestObject o = new EnumTestObject(); ObjectWrapper wrapper = GetWrapper(o); wrapper.SetPropertyValue("FileMode", FileMode.Create); Assert.AreEqual(FileMode.Create, (FileMode) wrapper.GetPropertyValue("FileMode")); }