コード例 #1
0
        public void IdTimestampWithMutableHeaders()
        {
            var accessor = new MessageHeaderAccessor();

            accessor.IdGenerator = new TestIdGenerator()
            {
                Id = MessageHeaders.ID_VALUE_NONE
            };
            accessor.EnableTimestamp = false;
            accessor.LeaveMutable    = true;
            var headers = accessor.MessageHeaders;

            Assert.Null(headers.Id);
            Assert.Null(headers.Timestamp);

            var id = Guid.NewGuid();

            accessor.IdGenerator = new TestIdGenerator()
            {
                Id = id
            };

            accessor.EnableTimestamp = true;
            accessor.SetImmutable();

            Assert.Equal(id, accessor.MessageHeaders.Id);
            Assert.NotNull(headers.Timestamp);
        }