public void SetNativeHeaderImmutable()
        {
            var headerAccessor = new NativeMessageHeaderAccessor();

            headerAccessor.SetNativeHeader("foo", "bar");
            headerAccessor.SetImmutable();
            var ex = Assert.Throws <InvalidOperationException>(() => headerAccessor.SetNativeHeader("foo", "baz"));

            Assert.Contains("Already immutable", ex.Message);
        }
        public void SetNativeHeaderLazyInitNullValue()
        {
            var headerAccessor = new NativeMessageHeaderAccessor();

            headerAccessor.SetNativeHeader("foo", null);

            Assert.Null(headerAccessor.GetNativeHeader("foo"));
            Assert.Null(headerAccessor.MessageHeaders[NativeMessageHeaderAccessor.NATIVE_HEADERS]);
        }
        public void SetNativeHeaderLazyInit()
        {
            var headerAccessor = new NativeMessageHeaderAccessor();

            headerAccessor.SetNativeHeader("foo", "baz");

            Assert.Equal(new List <string>()
            {
                "baz"
            }, headerAccessor.GetNativeHeader("foo"));
        }
Beispiel #4
0
        public void SetNativeHeaderNullValue()
        {
            var nativeHeaders = new Dictionary <string, List <string> >();

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

            var headers = new NativeMessageHeaderAccessor(nativeHeaders);

            headers.SetNativeHeader("foo", null);

            Assert.Null(headers.GetNativeHeader("foo"));
        }
        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"]);
        }
Beispiel #6
0
        public void SetNativeHeader()
        {
            var nativeHeaders = new Dictionary <string, List <string> >();

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

            var headers = new NativeMessageHeaderAccessor(nativeHeaders);

            headers.SetNativeHeader("foo", "baz");

            Assert.Equal(new List <string>()
            {
                "baz"
            }, headers.GetNativeHeader("foo"));
        }