public void DeserializeOperationRequest() { var buffer = new byte[] { 0x71, 0x64, 0x00, 0x02, 0x00, 0x73, 0x00, 0x05, 0x74, 0x65, 0x73, 0x74, 0x31, 0x01, 0x73, 0x00, 0x05, 0x74, 0x65, 0x73, 0x74, 0x32, }; var stream = new Protocol16Stream(buffer); byte typeCode = (byte)stream.ReadByte(); OperationRequest result = Protocol16Deserializer.Deserialize(stream, typeCode) as OperationRequest; Assert.NotNull(result); Assert.AreEqual(100, result.OperationCode); Assert.AreEqual("test1", result.Parameters[0]); Assert.AreEqual("test2", result.Parameters[1]); }
public void DeserializeOperationResponse() { var buffer = new byte[] { 0x70, 0x64, 0x00, 0x65, 0x2a, 0x00, 0x02, 0x00, 0x73, 0x00, 0x05, 0x74, 0x65, 0x73, 0x74, 0x31, 0x01, 0x73, 0x00, 0x05, 0x74, 0x65, 0x73, 0x74, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; var stream = new Protocol16Stream(buffer); byte typeCode = (byte)stream.ReadByte(); OperationResponse result = Protocol16Deserializer.Deserialize(stream, typeCode) as OperationResponse; Assert.NotNull(result); Assert.AreEqual(result.OperationCode, 100); Assert.AreEqual(result.ReturnCode, 101); Assert.AreEqual(result.Parameters[0], "test1"); Assert.AreEqual(result.Parameters[1], "test2"); }
public void DeserializeOperationResponseWithDebugMessage() { var buffer = new byte[] { 0x70, 0x64, 0x00, 0x66, 0x73, 0x00, 0x11, 0x53, 0x6F, 0x6D, 0x65, 0x44, 0x65, 0x62, 0x75, 0x67, 0x20, 0x6D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x00, 0x02, 0x00, 0x73, 0x00, 0x05, 0x74, 0x65, 0x73, 0x74, 0x31, 0x01, 0x69, 0x00, 0x00, 0x00, 0x02, }; var stream = new Protocol16Stream(buffer); byte typeCode = (byte)stream.ReadByte(); OperationResponse result = Protocol16Deserializer.Deserialize(stream, typeCode) as OperationResponse; Assert.NotNull(result); Assert.AreEqual(result.OperationCode, 100); Assert.AreEqual(result.ReturnCode, 102); Assert.AreEqual(result.DebugMessage, "SomeDebug message"); Assert.AreEqual(result.Parameters[0], "test1"); Assert.AreEqual(result.Parameters[1], 2); }