Beispiel #1
0
        public void EncodeDecode_WhenMultipleHeaders()
        {
            Random rnd = new Random();

            Byte[] b = new Byte[10000];
            rnd.NextBytes(b);

            Message expectedMessage = new Message(
                new Dictionary <string, string>()
            {
                { "Host", "google.com" },
                { "MyHeader", "custom value" },
                { "Test", "paulovich.net" }
            },
                b
                );

            BinaryMessageCodec codec = new BinaryMessageCodec();

            byte[]  binaryData    = codec.Encode(expectedMessage);
            Message actualMessage = codec.Decode(binaryData);

            Assert.NotNull(actualMessage);
            Assert.Equal(expectedMessage.Headers.Count, actualMessage.Headers.Count);

            foreach (var header in expectedMessage.Headers)
            {
                Assert.True(actualMessage.Headers.ContainsKey(header.Key));
                Assert.Equal(header.Value, actualMessage.Headers[header.Key]);
            }

            Assert.Equal(expectedMessage.Payload, actualMessage.Payload);
        }
Beispiel #2
0
        public void EncodeDecode_WhenEmptyHeaders()
        {
            Random rnd = new Random();

            Byte[] b = new Byte[10000];
            rnd.NextBytes(b);

            Message expectedMessage = new Message(
                new Dictionary <string, string>()
            {
            },
                b
                );

            BinaryMessageCodec codec = new BinaryMessageCodec();

            byte[]  binaryData    = codec.Encode(expectedMessage);
            Message actualMessage = codec.Decode(binaryData);

            Assert.NotNull(actualMessage);
            Assert.Equal(0, actualMessage.Headers.Count);
            Assert.Equal(expectedMessage.Headers.Count, actualMessage.Headers.Count);
            Assert.Equal(expectedMessage.Payload, actualMessage.Payload);
        }