示例#1
0
        public void BuildPropertyExtractorCollectionGivesPrecedenceToSchemaExtractorsOverPipelineExtractors()
        {
            using (var inputStream = new MemoryStream(Encoding.UTF8.GetBytes("<root xmlns='urn:ns'></root>")))
            {
                var annotationsMock = new Mock <ISchemaAnnotations>();
                annotationsMock.Setup(am => am.Extractors).Returns(
                    new PropertyExtractorCollection(
                        new XPathExtractor(BizTalkFactoryProperties.SenderName.QName, "/letter/*/to", ExtractionMode.Demote),
                        new XPathExtractor(TrackingProperties.Value2.QName, "/letter/*/salutations")));
                SchemaMetadataMock = new Mock <ISchemaMetadata>();
                SchemaMetadataMock.Setup(sm => sm.Annotations).Returns(annotationsMock.Object);
                SchemaBaseExtensions.SchemaMetadataFactory = type => SchemaMetadataMock.Object;

                MessageMock.Object.BodyPart.Data = inputStream;
                MessageMock.Setup(m => m.GetProperty(BtsProperties.MessageType)).Returns("urn:ns#root");

                var sut = new ContextPropertyExtractor {
                    Extractors = new[] {
                        new XPathExtractor(BizTalkFactoryProperties.SenderName.QName, "/letter/*/from", ExtractionMode.Promote),
                        new XPathExtractor(TrackingProperties.Value1.QName, "/letter/*/paragraph")
                    }
                };
                var extractors = sut.BuildPropertyExtractorCollection(PipelineContextMock.Object, MessageMock.Object);

                Assert.That(
                    extractors,
                    Is.EqualTo(
                        new[] {
                    new XPathExtractor(BizTalkFactoryProperties.SenderName.QName, "/letter/*/to", ExtractionMode.Demote),
                    new XPathExtractor(TrackingProperties.Value2.QName, "/letter/*/salutations"),
                    new XPathExtractor(TrackingProperties.Value1.QName, "/letter/*/paragraph")
                }));
            }
        }
示例#2
0
        public void BuildPropertyExtractorCollectionYieldsPipelineExtractorsWhenNoSchemaExtractors()
        {
            using (var inputStream = new MemoryStream(Encoding.UTF8.GetBytes("<root xmlns='urn:ns'></root>")))
            {
                MessageMock.Object.BodyPart.Data = inputStream;
                MessageMock.Setup(m => m.GetProperty(BtsProperties.MessageType)).Returns("urn:ns#root");

                var sut = new ContextPropertyExtractor {
                    Extractors = new[] {
                        new XPathExtractor(BizTalkFactoryProperties.SenderName.QName, "/letter/*/from", ExtractionMode.Promote),
                        new XPathExtractor(TrackingProperties.Value1.QName, "/letter/*/paragraph")
                    }
                };
                var extractors = sut.BuildPropertyExtractorCollection(PipelineContextMock.Object, MessageMock.Object);

                Assert.That(extractors, Is.EqualTo(sut.Extractors));
            }
        }