public void DecodeWithInvalidName() { MessageCoder coder = new MessageCoder(); bool result = coder.Decode(invalidEncodedResult); Assert.False(result); }
public void DecodeWithValidName() { MessageCoder coder = new MessageCoder(); bool result = coder.Decode(validEncodedResult); Assert.True(result); Assert.Equal(nameToTest, coder.Name); }
/// <summary> /// Handles the messages received by this consumer. /// </summary> /// <remarks>There is no exception handling here. Hanlding invalid responses should be a normal part of the flow.</remarks> private static void Consumer_Received(object sender, BasicDeliverEventArgs e) { var body = e.Body; var message = Encoding.UTF8.GetString(body); MessageCoder coder = new MessageCoder(); // Try and decode the message. if (coder.Decode(message)) { PrintValidMessageRecieved(coder.Name); } else { IndicateInvalidMessageRecieved(message); } }
public IMessageProtocol ToMessageProtocol() { return(Bytes?.Length > 0 ? MessageCoder.Decode(Bytes) : null); }