public void ValidateTransformClaimTokenWithEmbeddedDataAndContext()
        {
            var contextMock = new MessageContextMock();

            contextMock
            .Setup(c => c.GetProperty(BizTalkFactoryProperties.MessageType))
            .Returns("context-claimed-message-type");
            contextMock
            .Setup(c => c.GetProperty(BizTalkFactoryProperties.CorrelationId))
            .Returns("context-correlation-token");
            contextMock
            .Setup(c => c.GetProperty(BizTalkFactoryProperties.EnvironmentTag))
            .Returns("context-environment-tag");
            contextMock
            .Setup(c => c.GetProperty(BizTalkFactoryProperties.ReceiverName))
            .Returns("context-receiver-name");

            using (var stream = ResourceManager.Load(Assembly.GetExecutingAssembly(), "Be.Stateless.BizTalk.Resources.Message.ClaimToken.3.xml"))
            {
                var setup = Given(input => input.Message(stream).Context(contextMock.Object))
                            .Transform
                            .OutputsXml(output => output.ConformingTo <CheckIn>().WithStrictConformanceLevel());
                var result = setup.Validate();
                result.Select("//usp:url/text()").Should().HaveCount(1);
                result.SelectSingleNode("//usp:correlationId/text()").Value.Should().Be("embedded-correlation-token");
                result.SelectSingleNode("//usp:environmentTag/text()").Value.Should().Be("embedded-environment-tag");
                result.SelectSingleNode("//usp:messageType/text()").Value.Should().Be("embedded-claimed-message-type");
                result.SelectSingleNode("//usp:receiverName/text()").Value.Should().Be("context-receiver-name");
                result.SelectSingleNode("//usp:senderName/text()").Value.Should().Be("embedded-sender-name");
                result.SelectSingleNode("//usp:any/text()").Value
                .Should().Be("<parent><child>one</child><child>two</child></parent><parent><child>six</child><child>ten</child></parent>");
            }
        }
Exemplo n.º 2
0
        public void ValidateTransformClaimTokenWithContext()
        {
            var contextMock = new MessageContextMock();

            contextMock
            .Setup(c => c.GetProperty(BizTalkFactoryProperties.ClaimedMessageType))
            .Returns("context-claimed-message-type");
            contextMock
            .Setup(c => c.GetProperty(BizTalkFactoryProperties.CorrelationToken))
            .Returns("context-correlation-token");
            contextMock
            .Setup(c => c.GetProperty(BizTalkFactoryProperties.EnvironmentTag))
            .Returns("context-environment-tag");

            using (var stream = ResourceManager.Load("Data.Token.1.xml"))
            {
                var setup = Given(input => input.Message(stream).Context(contextMock.Object))
                            .Transform
                            .OutputsXml(output => output.ConformingTo <CheckIn>().WithStrictConformanceLevel());
                var result = setup.Validate();
                Assert.That(result.Select("//usp:url/text()").Count, Is.EqualTo(1));
                Assert.That(result.SelectSingleNode("//usp:messageType/text()").Value, Is.EqualTo("context-claimed-message-type"));
                Assert.That(result.SelectSingleNode("//usp:correlationToken/text()").Value, Is.EqualTo("context-correlation-token"));
                Assert.That(result.SelectSingleNode("//usp:environmentTag/text()").Value, Is.EqualTo("context-environment-tag"));
            }
        }
        public void ValidateTransformWithEnvironmentTagAndPartition()
        {
            var contextMock = new MessageContextMock();

            contextMock
            .Setup(c => c.GetProperty(BatchProperties.EnvelopeSpecName))
            .Returns("envelope-name");
            contextMock
            .Setup(c => c.GetProperty(BizTalkFactoryProperties.EnvironmentTag))
            .Returns("Tag");
            contextMock
            .Setup(c => c.GetProperty(BatchProperties.EnvelopePartition))
            .Returns("A");
            contextMock
            .Setup(c => c.GetProperty(TrackingProperties.MessagingStepActivityId))
            .Returns("D4D3A8E583024BAC9D35EC98C5422E82");

            using (var stream = new StringStream("<?xml version=\"1.0\" encoding=\"utf-16\" ?><root>content of a part is irrelevant here</root>"))
            {
                var setup = Given(input => input.Message(stream).Context(contextMock.Object))
                            .Transform
                            .OutputsXml(output => output.ConformingTo <AddPart>().WithStrictConformanceLevel());
                var result = setup.Validate();
                result.SelectSingleNode("//usp:envelopeSpecName") !.Value.Should().Be("envelope-name");
                result.SelectSingleNode("//usp:environmentTag") !.Value.Should().Be("Tag");
                result.SelectSingleNode("//usp:partition") !.Value.Should().Be("A");
                result.SelectSingleNode("//usp:messagingStepActivityId") !.Value.Should().Be("D4D3A8E583024BAC9D35EC98C5422E82");
            }
        }
 public SftpOutboundTransportLocationBuilderFixture()
 {
     MessageContextMock = new MessageContextMock();
     MessageContextMock
     .Setup(c => c.GetProperty(BtsProperties.OutboundTransportCLSID))
     .Returns("{C166A7E5-4F4C-4B02-A6F2-8BE07E1FA786}");
     MessageContextMock
     .Setup(c => c.GetProperty(SftpProperties.FolderPath))
     .Returns("/Files/Drops/Party");
     MessageContextMock
     .Setup(c => c.GetProperty(SftpProperties.TargetFileName))
     .Returns(@"%MessageID%.xml");
 }
 public FileOutboundTransportLocationBuilderFixture()
 {
     MessageContextMock = new();
     MessageContextMock
     .Setup(c => c.GetProperty(BtsProperties.OutboundTransportCLSID))
     .Returns("{9D0E4341-4CCE-4536-83FA-4A5040674AD6}");
 }
Exemplo n.º 6
0
 public void ReadInteger()
 {
     MessageContextMock.Setup(c => c.Read(BtsProperties.RetryCount.Name, BtsProperties.RetryCount.Namespace)).Returns(null);
     Assert.That(MessageContextMock.Object.GetProperty(BtsProperties.RetryCount), Is.Null);
     MessageContextMock.Setup(c => c.Read(BtsProperties.RetryCount.Name, BtsProperties.RetryCount.Namespace)).Returns("2");
     Assert.That(MessageContextMock.Object.GetProperty(BtsProperties.RetryCount), Is.EqualTo(2));
 }
Exemplo n.º 7
0
 public void ReadDateTime()
 {
     MessageContextMock.Setup(c => c.Read(FileProperties.FileCreationTime.Name, FileProperties.FileCreationTime.Namespace)).Returns(null);
     Assert.That(MessageContextMock.Object.GetProperty(FileProperties.FileCreationTime), Is.Null);
     MessageContextMock.Setup(c => c.Read(FileProperties.FileCreationTime.Name, FileProperties.FileCreationTime.Namespace)).Returns("2012-12-01");
     Assert.That(MessageContextMock.Object.GetProperty(FileProperties.FileCreationTime), Is.EqualTo(new DateTime(2012, 12, 1)));
     MessageContextMock.Setup(c => c.Read(FileProperties.FileCreationTime.Name, FileProperties.FileCreationTime.Namespace)).Returns("2017-09-15T10:19:06");
     Assert.That(MessageContextMock.Object.GetProperty(FileProperties.FileCreationTime), Is.EqualTo(new DateTime(2017, 9, 15, 10, 19, 6)));
 }
Exemplo n.º 8
0
 public void ReadBoolean()
 {
     MessageContextMock.Setup(c => c.Read(BtsProperties.AckRequired.Name, BtsProperties.AckRequired.Namespace)).Returns(null);
     Assert.That(MessageContextMock.Object.GetProperty(BtsProperties.AckRequired), Is.Null);
     MessageContextMock.Setup(c => c.Read(BtsProperties.AckRequired.Name, BtsProperties.AckRequired.Namespace)).Returns("true");
     Assert.That(MessageContextMock.Object.GetProperty(BtsProperties.AckRequired), Is.True);
     MessageContextMock.Setup(c => c.Read(BtsProperties.AckRequired.Name, BtsProperties.AckRequired.Namespace)).Returns("True");
     Assert.That(MessageContextMock.Object.GetProperty(BtsProperties.AckRequired), Is.True);
 }
        public void ThrowsWhenNotUsedWithMicrosoftSftpAdapter()
        {
            MessageContextMock
            .Setup(c => c.GetProperty(BtsProperties.OutboundTransportCLSID))
            .Returns("{9D0E4341-4CCE-4536-83FA-4A5040674AD6}");

            Action(() => new SftpOutboundTransportLocationBuilder().Execute(MessageContextMock.Object))
            .Should().Throw <InvalidOperationException>()
            .WithMessage("Outbound SFTP transport is required on this leg of the message exchange pattern.");
        }
        public void ThrowsWhenNotUsedWithFileAdapter()
        {
            MessageContextMock
            .Setup(c => c.GetProperty(BtsProperties.OutboundTransportCLSID))
            .Returns("{C166A7E5-4F4C-4B02-A6F2-8BE07E1FA786}");

            Invoking(() => new FileOutboundTransportLocationBuilder().Execute(MessageContextMock.Object))
            .Should().Throw <InvalidOperationException>()
            .WithMessage("Outbound file transport is required on this leg of the message exchange pattern.");
        }
        public void ThrowsWhenNoOutboundTransportLocation()
        {
            MessageContextMock
            .Setup(c => c.GetProperty(BtsProperties.OutboundTransportLocation))
            .Returns(@"C:\Files\Drops\Party\%MessageID%.xml");

            Invoking(() => new FileOutboundTransportLocationBuilder().Execute(MessageContextMock.Object))
            .Should().Throw <InvalidOperationException>()
            .WithMessage("Target sub path and file name were expected to be found in BizTalkFactoryProperties.OutboundTransportLocation context property.");
        }
        public void OutboundTransportLocationHasRootedFolderAndFile()
        {
            MessageContextMock
            .Setup(c => c.GetProperty(BizTalkFactoryProperties.OutboundTransportLocation))
            .Returns(@"\Folder\File.txt");

            new SftpOutboundTransportLocationBuilder().Execute(MessageContextMock.Object);

            MessageContextMock.Verify(c => c.SetProperty(BtsProperties.IsDynamicSend, true));
            MessageContextMock.Verify(c => c.SetProperty(SftpProperties.FolderPath, "/Folder"));
            MessageContextMock.Verify(c => c.SetProperty(SftpProperties.TargetFileName, @"File.txt"));
        }
Exemplo n.º 13
0
        public void OutboundTransportLocationHasRootedFolderAndFile()
        {
            MessageContextMock
            .Setup(c => c.GetProperty(BizTalkFactoryProperties.OutboundTransportLocation))
            .Returns(@"\folder\file.txt");

            new SftpOutboundTransportLocationBuilder().Execute(MessageContextMock.Object);

            MessageContextMock.Verify(
                c => c.SetProperty(
                    BtsProperties.OutboundTransportLocation,
                    "sftp://sftp.world.com:22/folder/file.txt"));
        }
        public void OutboundTransportLocationIsUncPath()
        {
            MessageContextMock
            .Setup(c => c.GetProperty(BtsProperties.OutboundTransportLocation))
            .Returns(@"\\server\%MessageID%.xml");
            MessageContextMock
            .Setup(c => c.GetProperty(BizTalkFactoryProperties.OutboundTransportLocation))
            .Returns(@"File.txt");

            new FileOutboundTransportLocationBuilder().Execute(MessageContextMock.Object);

            MessageContextMock.Verify(c => c.SetProperty(BtsProperties.OutboundTransportLocation, @"\\server\File.txt"));
        }
Exemplo n.º 15
0
 public SftpOutboundTransportLocationBuilderFixture()
 {
     MessageContextMock = new();
     MessageContextMock
     .Setup(c => c.GetProperty(BtsProperties.OutboundTransportLocation))
     .Returns("sftp://sftp.world.com:22/files/drops/party/%MessageID%.xml");
     MessageContextMock
     .Setup(c => c.GetProperty(BtsProperties.OutboundTransportCLSID))
     .Returns("{C166A7E5-4F4C-4B02-A6F2-8BE07E1FA786}");
     MessageContextMock
     .Setup(c => c.GetProperty(SftpProperties.FolderPath))
     .Returns("/files/drops/party");
 }
Exemplo n.º 16
0
        public void ExecuteDemotesLocalNameValueInContextAndKeepOriginalPrefix()
        {
            var messageContextMock = new MessageContextMock();

            messageContextMock.Setup(c => c.GetProperty(BizTalkFactoryProperties.ReceiverName)).Returns("new-value");
            var newValue = string.Empty;

            var sut = new QNameValueExtractor(BizTalkFactoryProperties.ReceiverName.QName, "/letter/*/to", ExtractionMode.Demote, QNameValueExtractionMode.LocalName);

            sut.Execute(messageContextMock.Object, "ns:value", ref newValue);

            messageContextMock.Verify(c => c.Promote(BizTalkFactoryProperties.ReceiverName, It.IsAny <string>()), Times.Never);
            Assert.That(newValue, Is.EqualTo("ns:new-value"));
        }
        public void OutboundTransportLocationHasRootedFolderAndFile()
        {
            MessageContextMock
            .Setup(c => c.GetProperty(BtsProperties.OutboundTransportLocation))
            .Returns(@"C:\Files\Drops\Party\%MessageID%.xml");

            MessageContextMock
            .Setup(c => c.GetProperty(BizTalkFactoryProperties.OutboundTransportLocation))
            .Returns(@"\Folder\File.txt");

            new FileOutboundTransportLocationBuilder().Execute(MessageContextMock.Object);

            MessageContextMock.Verify(c => c.SetProperty(BtsProperties.OutboundTransportLocation, @"\Folder\File.txt"));
        }
Exemplo n.º 18
0
        public void ExecuteDemotesLocalNameValueInContextAndKeepOriginalPrefix()
        {
            var messageContextMock = new MessageContextMock();

            messageContextMock.Setup(c => c.GetProperty(BizTalkFactoryProperties.OutboundTransportLocation)).Returns("new-value");
            var newValue = string.Empty;

            var sut = new QNameValueExtractor(BizTalkFactoryProperties.OutboundTransportLocation.QName, "/letter/*/to", ExtractionMode.Demote, QNameValueExtractionMode.LocalName);

            sut.Execute(messageContextMock.Object, "ns:value", ref newValue);

            messageContextMock.Verify(c => c.Promote(BizTalkFactoryProperties.OutboundTransportLocation, It.IsAny <string>()), Times.Never);
            newValue.Should().Be("ns:new-value");
        }
        public void ValidateTransform()
        {
            var contextMock = new MessageContextMock();

            contextMock
            .Setup(c => c.GetProperty(BatchProperties.EnvelopeSpecName))
            .Returns("envelope-name");

            using (var stream = new StringStream("<?xml version=\"1.0\" encoding=\"utf-16\" ?><root>content of a part is irrelevant here</root>"))
            {
                var setup = Given(input => input.Message(stream).Context(contextMock.Object))
                            .Transform
                            .OutputsXml(output => output.ConformingTo <AddPart>().WithStrictConformanceLevel());
                var result = setup.Validate();
                result.SelectSingleNode("//usp:envelopeSpecName") !.Value.Should().Be("envelope-name");
                result.Select("//usp:partition").Should().BeEmpty();
                result.Select("//usp:messagingStepActivityId").Should().BeEmpty();
            }
        }
Exemplo n.º 20
0
        public void MatchAndDemote()
        {
            var extractors = new[] {
                new XPathExtractor(BizTalkFactoryProperties.ContextBuilderTypeName.QName, "/letter/*/paragraph[1]", ExtractionMode.Demote),
                new XPathExtractor(BizTalkFactoryProperties.ContextBuilderTypeName.QName, "/letter/*/paragraph[2]", ExtractionMode.Demote),
                new XPathExtractor(BizTalkFactoryProperties.ContextBuilderTypeName.QName, "/letter/*/paragraph[3]", ExtractionMode.Demote)
            };

            using (var stream = XPathMutatorStreamFactory.Create(new StringStream(UNQUALIFIED_LETTER), extractors, () => MessageContextMock.Object))
                using (var reader = new StreamReader(stream))
                {
                    MessageContextMock.Setup(c => c.GetProperty(BizTalkFactoryProperties.ContextBuilderTypeName)).Returns("same-paragraph");
                    reader.ReadToEnd()
                    .Should().Be(
                        UNQUALIFIED_LETTER
                        .Replace("paragraph-one", "same-paragraph")
                        .Replace("paragraph-two", "same-paragraph")
                        .Replace("paragraph-six", "same-paragraph")
                        );
                }
        }
Exemplo n.º 21
0
        public void MatchAndDemote()
        {
            var extractors = new[] {
                new XPathExtractor(TrackingProperties.Value1.QName, "/letter/*/paragraph[1]", ExtractionMode.Demote),
                new XPathExtractor(TrackingProperties.Value1.QName, "/letter/*/paragraph[2]", ExtractionMode.Demote),
                new XPathExtractor(TrackingProperties.Value1.QName, "/letter/*/paragraph[3]", ExtractionMode.Demote)
            };

            using (var stream = XPathMutatorStreamFactory.Create(ResourceManager.Load("Data.UnqualifiedLetter.xml"), extractors, () => MessageContextMock.Object))
                using (var reader = new StreamReader(stream))
                {
                    MessageContextMock.Setup(c => c.GetProperty(TrackingProperties.Value1)).Returns("same-paragraph");
                    Assert.That(
                        reader.ReadToEnd(),
                        Is.EqualTo(
                            ResourceManager
                            .LoadString("Data.UnqualifiedLetter.xml")
                            .Substring(38)                             // skip xml declaration
                            .Replace("paragraph-one", "same-paragraph")
                            .Replace("paragraph-two", "same-paragraph")
                            .Replace("paragraph-six", "same-paragraph")
                            ));
                }
        }