Exemplo n.º 1
0
        public void DecodeWithInvalidName()
        {
            MessageCoder coder = new MessageCoder();

            bool result = coder.Decode(invalidEncodedResult);

            Assert.False(result);
        }
Exemplo n.º 2
0
        public void DecodeWithValidName()
        {
            MessageCoder coder = new MessageCoder();

            bool result = coder.Decode(validEncodedResult);

            Assert.True(result);
            Assert.Equal(nameToTest, coder.Name);
        }
Exemplo n.º 3
0
        /// <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);
            }
        }
Exemplo n.º 4
0
 public IMessageProtocol ToMessageProtocol()
 {
     return(Bytes?.Length > 0 ? MessageCoder.Decode(Bytes) : null);
 }