public void MessageToByteSerializationTest() { Status message = MessagesFactory.CreateEmptyMessage(MessageType.StatusMessage).Cast <Status>(); message.Id = 1234; message.Threads = new StatusThread[1] { new StatusThread() { ProblemType = "DVRP", HowLong = 1234, HowLongSpecified = true, State = StatusThreadState.Busy } }; MessageToBytesConverter converter = new MessageToBytesConverter(); byte[] bytes = converter.ToByteArray(message); Message messageDeserialized = converter.FromBytesArray(bytes); Assert.AreEqual(MessageType.StatusMessage, messageDeserialized.MessageType); Status mStatus = messageDeserialized.Cast <Status>(); Assert.AreEqual(message.Id, mStatus.Id); Assert.AreEqual(message.Threads.Length, mStatus.Threads.Length); }
public void OneMessageToBytesTest() { MessageToBytesConverter converter = new MessageToBytesConverter(); Message msg = new NoOperation(); byte[] bytes = converter.ToByteArray(msg); Message outMsg = converter.FromBytesArray(bytes); Assert.AreEqual(msg.GetType(), outMsg.GetType()); }