Beispiel #1
0
        protected void ContextPropertyExtractorPromotesConstant(ReceivePipelineWrapper pipeline)
        {
            const string content = "<ns0:Root xmlns:ns0=\"http://schemas.microsoft.com/BizTalk/2003/Any\"><message>content</message></ns0:Root>";

            using (var stream = new StringStream(content))
            {
                pipeline.AddDocSpec(typeof(Any));
                var microPipeline = (MicroPipelineComponent)pipeline.GetComponent(PipelineStage.Decode, 1);
                microPipeline.Components = new[] {
                    new ContextPropertyExtractor {
                        Extractors = new[] {
                            new ConstantExtractor(BizTalkFactoryProperties.EnvironmentTag.QName, "tag", ExtractionMode.Promote)
                        }
                    }
                };

                var inputMessage = MessageHelper.CreateFromStream(stream);
                inputMessage.GetProperty(BizTalkFactoryProperties.EnvironmentTag).Should().BeNull();
                inputMessage.IsPromoted(BizTalkFactoryProperties.EnvironmentTag).Should().BeFalse();

                var outputMessages = pipeline.Execute(inputMessage);

                outputMessages[0].GetProperty(BizTalkFactoryProperties.EnvironmentTag).Should().Be("tag");
                outputMessages[0].IsPromoted(BizTalkFactoryProperties.EnvironmentTag).Should().BeTrue();
                using (var reader = new StreamReader(outputMessages[0].BodyPart.Data))
                {
                    var readOuterXml = reader.ReadToEnd();
                    readOuterXml.Should().Be(content);
                }
                outputMessages[0].GetProperty(BizTalkFactoryProperties.EnvironmentTag).Should().Be("tag");
                outputMessages[0].IsPromoted(BizTalkFactoryProperties.EnvironmentTag).Should().BeTrue();
            }
        }