public void DoesNothingWhenNoXslt() { using (var probeStreamMockInjectionScope = new ProbeStreamMockInjectionScope()) using (var transformStreamMockInjectionScope = new TransformStreamMockInjectionScope()) { var sut = new XsltRunner(); sut.MapType.Should().BeNull(); sut.Execute(PipelineContextMock.Object, MessageMock.Object); probeStreamMockInjectionScope.Mock.VerifyGet(ps => ps.MessageType, Times.Never()); transformStreamMockInjectionScope.Mock.Verify(ps => ps.Apply(It.IsAny <Type>()), Times.Never()); } }
public void MessageTypeIsProbedWhenUnknown() { using (var probeStreamMockInjectionScope = new ProbeStreamMockInjectionScope()) using (var inputStream = new MemoryStream(Encoding.UTF8.GetBytes("non xml payload"))) { MessageMock.Object.BodyPart.Data = inputStream; MessageMock.Setup(m => m.GetProperty(BtsProperties.OutboundTransportLocation)).Returns("outbound-transport-location"); var sut = new SBMessagingContextPropagator(); sut.Execute(PipelineContextMock.Object, MessageMock.Object); probeStreamMockInjectionScope.Mock.VerifyGet(ps => ps.MessageType, Times.Once); } }
public void XsltEntailsMessageTypeIsPromoted() { using (var stream = new StringStream("<root xmlns='urn:ns'></root>")) using (var transformedStream = stream.Transform().Apply(typeof(IdentityTransform))) using (var probeStreamMockInjectionScope = new ProbeStreamMockInjectionScope()) using (var probeBatchContentStreamMockInjectionScope = new ProbeBatchContentStreamMockInjectionScope()) using (var transformStreamMockInjectionScope = new TransformStreamMockInjectionScope()) { PipelineContextMock .Setup(m => m.GetDocumentSpecByType(SchemaMetadata.For <Envelope>().MessageType)) .Returns(SchemaMetadata.For <AddPart>().DocumentSpec); MessageMock.Object.BodyPart.Data = stream; probeStreamMockInjectionScope.Mock .Setup(ps => ps.MessageType) .Returns(SchemaMetadata.For <Envelope>().MessageType); probeBatchContentStreamMockInjectionScope.Mock .Setup(ps => ps.BatchDescriptor) .Returns(new BatchDescriptor { EnvelopeSpecName = SchemaMetadata.For <Envelope>().DocumentSpec.DocSpecStrongName }); transformStreamMockInjectionScope.Mock .Setup(ts => ts.ExtendWith(MessageMock.Object.Context)) .Returns(transformStreamMockInjectionScope.Mock.Object); transformStreamMockInjectionScope.Mock .Setup(ts => ts.Apply(typeof(IdentityTransform), Encoding.UTF8)) .Returns(transformedStream); var sut = new EnvelopeBuilder { Encoding = Encoding.UTF8, MapType = typeof(IdentityTransform) }; sut.Execute(PipelineContextMock.Object, MessageMock.Object); MessageMock.Verify(m => m.Promote(BtsProperties.MessageType, SchemaMetadata.For <AddPart>().MessageType), Times.Once); MessageMock.Verify(m => m.Promote(BtsProperties.MessageType, It.IsAny <string>()), Times.Once); MessageMock.Verify(m => m.Promote(BtsProperties.SchemaStrongName, SchemaMetadata.For <AddPart>().DocumentSpec.DocSpecStrongName), Times.Once); MessageMock.Verify(m => m.Promote(BtsProperties.SchemaStrongName, It.IsAny <string>()), Times.Once); } }