public void TestToString() { NmsObjectMessage objectMessage = factory.CreateObjectMessage(); Assert.True(objectMessage.ToString().StartsWith("NmsObjectMessage")); }
public static NmsMessage TransformMessage(INmsMessageFactory factory, IMessage message) { NmsMessage nmsMessage = null; if (message is IBytesMessage bytesMessage) { bytesMessage.Reset(); NmsBytesMessage msg = factory.CreateBytesMessage(); try { while (true) { // Reads a byte from the message stream until the stream is empty msg.WriteByte(bytesMessage.ReadByte()); } } catch (MessageEOFException) { // Indicates all the bytes have been read from the source. } nmsMessage = msg; } else if (message is IMapMessage mapMessage) { NmsMapMessage msg = factory.CreateMapMessage(); CopyMap(mapMessage.Body, msg.Body); nmsMessage = msg; } else if (message is IObjectMessage objectMessage) { NmsObjectMessage msg = factory.CreateObjectMessage(); msg.Body = objectMessage.Body; nmsMessage = msg; } else if (message is IStreamMessage streamMessage) { streamMessage.Reset(); NmsStreamMessage msg = factory.CreateStreamMessage(); try { while (true) { // Reads a byte from the message stream until the stream is empty msg.WriteObject(streamMessage.ReadObject()); } } catch (MessageEOFException) { // Indicates all the stream have been read from the source. } nmsMessage = msg; } else if (message is ITextMessage textMessage) { NmsTextMessage msg = factory.CreateTextMessage(); msg.Text = textMessage.Text; nmsMessage = msg; } else { nmsMessage = factory.CreateMessage(); } CopyProperties(message, nmsMessage); return(nmsMessage); }