Пример #1
0
        public void DecodeWithInvalidName()
        {
            MessageCoder coder = new MessageCoder();

            bool result = coder.Decode(invalidEncodedResult);

            Assert.False(result);
        }
Пример #2
0
        public void DecodeWithValidName()
        {
            MessageCoder coder = new MessageCoder();

            bool result = coder.Decode(validEncodedResult);

            Assert.True(result);
            Assert.Equal(nameToTest, coder.Name);
        }
Пример #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);
            }
        }
Пример #4
0
 public IMessageProtocol ToMessageProtocol()
 {
     return(Bytes?.Length > 0 ? MessageCoder.Decode(Bytes) : null);
 }