public void CreateFromMessage()
        {
            var inputNativeHeaders = new Dictionary <string, List <string> >
            {
                { "foo", new List <string>()
                  {
                      "bar"
                  } },
                { "bar", new List <string>()
                  {
                      "baz"
                  } }
            };

            var inputHeaders = new Dictionary <string, object>
            {
                { "a", "b" },
                { NativeMessageHeaderAccessor.NATIVE_HEADERS, inputNativeHeaders }
            };

            var message        = Message.Create <string>("p", inputHeaders);
            var headerAccessor = new NativeMessageHeaderAccessor(message);
            var actual         = headerAccessor.ToDictionary();

            Assert.Equal(2, actual.Count);
            Assert.Equal("b", actual["a"]);
            Assert.NotNull(actual[NativeMessageHeaderAccessor.NATIVE_HEADERS]);
            Assert.Equal(inputNativeHeaders, actual[NativeMessageHeaderAccessor.NATIVE_HEADERS]);
            Assert.NotSame(inputNativeHeaders, actual[NativeMessageHeaderAccessor.NATIVE_HEADERS]);
        }
        public void CreateFromMessageNull()
        {
            var headerAccessor = new NativeMessageHeaderAccessor((IMessage)null);

            var actual = headerAccessor.ToDictionary();

            Assert.Empty(actual);

            var actualNativeHeaders = headerAccessor.ToNativeHeaderDictionary();

            Assert.Empty(actualNativeHeaders);
        }
        public void CreateFromMessageAndModify()
        {
            var inputNativeHeaders = new Dictionary <string, List <string> >
            {
                { "foo", new List <string>()
                  {
                      "bar"
                  } },
                { "bar", new List <string>()
                  {
                      "baz"
                  } }
            };

            var nativeHeaders = new Dictionary <string, object>
            {
                { "a", "b" },
                { NativeMessageHeaderAccessor.NATIVE_HEADERS, inputNativeHeaders }
            };

            var message = Message.Create <string>("p", nativeHeaders);

            var headerAccessor = new NativeMessageHeaderAccessor(message);

            headerAccessor.SetHeader("a", "B");
            headerAccessor.SetNativeHeader("foo", "BAR");

            var actual = headerAccessor.ToDictionary();

            Assert.Equal(2, actual.Count);
            Assert.Equal("B", actual["a"]);

            var actualNativeHeaders =
                (IDictionary <string, List <string> >)actual[NativeMessageHeaderAccessor.NATIVE_HEADERS];

            Assert.NotNull(actualNativeHeaders);
            Assert.Equal(new List <string>()
            {
                "BAR"
            }, actualNativeHeaders["foo"]);
            Assert.Equal(new List <string>()
            {
                "baz"
            }, actualNativeHeaders["bar"]);
        }
예제 #4
0
        public void CreateFromNativeHeaderMap()
        {
            var inputNativeHeaders = new Dictionary <string, List <string> >();

            inputNativeHeaders.Add("foo", new List <string>()
            {
                "bar"
            });
            inputNativeHeaders.Add("bar", new List <string>()
            {
                "baz"
            });

            var headerAccessor = new NativeMessageHeaderAccessor(inputNativeHeaders);
            var actual         = headerAccessor.ToDictionary();

            Assert.Single(actual);
            Assert.NotNull(actual[NativeMessageHeaderAccessor.NATIVE_HEADERS]);
            Assert.Equal(inputNativeHeaders, actual[NativeMessageHeaderAccessor.NATIVE_HEADERS]);
            Assert.NotSame(inputNativeHeaders, actual[NativeMessageHeaderAccessor.NATIVE_HEADERS]);
        }