public void BuildsStringMessageCorrectly() { var payload = "Hello there!"; var message = new MessageBuilder() .PutOperationCode("12") .PutPayload(payload) .Build(); var decoded = MessageDecoder.Decode(message.Skip(sizeof(int)).ToArray()); Assert.IsFalse(decoded.IsResponse); Assert.AreEqual("------", decoded.Auth); Assert.AreEqual("12", decoded.Code); Assert.AreEqual(payload, MessageDecoder.DecodePayload(decoded.Payload)); }
public void BuildsObjectMessageCorrectly() { var user = new User() { Id = 3, Name = "El hijo de Piri" }; var message = new MessageBuilder() .PutOperationCode("14") .PutPayload(user) .Build(); var decoded = MessageDecoder.Decode(message.Skip(sizeof(int)).ToArray()); var payload = MessageDecoder.DecodePayload <User>(decoded.Payload); Assert.IsFalse(decoded.IsResponse); Assert.AreEqual("------", decoded.Auth); Assert.AreEqual("14", decoded.Code); Assert.AreEqual(user.Id, payload.Id); Assert.AreEqual(user.Name, payload.Name); }