Beispiel #1
0
        public void ZipEntryNameIsDerivedFromOutboundTransportLocation()
        {
            var sut = new ZipEncoder();

            Assert.That(
                () => sut.Execute(PipelineContextMock.Object, MessageMock.Object),
                Throws.TypeOf <InvalidOperationException>()
                .With.Message.EqualTo("BizTalkFactoryProperties.OutboundTransportLocation has to be set in context in order to determine zip entry name."));
        }
Beispiel #2
0
        public void OutboundTransportLocationWithOnlyFilename()
        {
            MessageMock
            .Setup(m => m.GetProperty(BizTalkFactoryProperties.OutboundTransportLocation))
            .Returns(@"file.txt");

            var sut = new ZipEncoder();

            sut.Execute(PipelineContextMock.Object, MessageMock.Object);

            MessageMock.Verify(m => m.SetProperty(BizTalkFactoryProperties.OutboundTransportLocation, "file.zip"));
        }
Beispiel #3
0
        public void OutboundTransportLocationAbsolutePathIsKeptUnchanged()
        {
            MessageMock
            .Setup(m => m.GetProperty(BizTalkFactoryProperties.OutboundTransportLocation))
            .Returns(@"\file.txt");

            var sut = new ZipEncoder();

            sut.Execute(PipelineContextMock.Object, MessageMock.Object);

            MessageMock.Verify(m => m.SetProperty(BizTalkFactoryProperties.OutboundTransportLocation, @"\file.zip"));
        }
Beispiel #4
0
        public void OutboundTransportLocationFileExtensionIsChangedToZip()
        {
            const string location = @"\\unc\folder\file.txt";

            MessageMock
            .Setup(m => m.GetProperty(BizTalkFactoryProperties.OutboundTransportLocation))
            .Returns(location);

            var sut = new ZipEncoder();

            sut.Execute(PipelineContextMock.Object, MessageMock.Object);

            MessageMock.Verify(m => m.SetProperty(BizTalkFactoryProperties.OutboundTransportLocation, location.Replace(".txt", ".zip")));
        }
Beispiel #5
0
        public void WrapsMessageStreamInZipOutputStream()
        {
            const string location = "sftp://host/folder/file.txt";

            MessageMock
            .Setup(m => m.GetProperty(BizTalkFactoryProperties.OutboundTransportLocation))
            .Returns(location);
            var bodyPart = new Mock <IBaseMessagePart>();

            bodyPart.Setup(p => p.GetOriginalDataStream()).Returns(new StringStream("content"));
            bodyPart.SetupProperty(p => p.Data);
            MessageMock.Setup(m => m.BodyPart).Returns(bodyPart.Object);

            var sut = new ZipEncoder();

            sut.Execute(PipelineContextMock.Object, MessageMock.Object);

            Assert.IsInstanceOf <ZipOutputStream>(MessageMock.Object.BodyPart.Data);
            var clearStream = new ZipInputStream(MessageMock.Object.BodyPart.Data);
            var entry       = clearStream.GetNextEntry();

            Assert.That(entry.Name, Is.EqualTo(System.IO.Path.GetFileName(location)));
        }