コード例 #1
0
        public void CopyAllInboundFromSftp()
        {
            //Arrange
            var channelSettings = new FromSettings()
            {
                Path       = "/home/ec2-user/From",
                Type       = ConfigChannelType.Sftp,
                PrivateKey = Path.Combine("Common", "key.private"),
                Host       = "127.0.0.1",
                Port       = 22,
                UserName   = "******",
            };

            _workingDirectory.DeleteWithContentIfExists().CreateIfNotExists();

            SftpChannel sftp = new SftpChannel(_workingDirectory, channelSettings);
            //Act
            var result = sftp.Copy();

            //Assert
            Assert.IsTrue(result.Any(d => d.Name == "EE_FEETRA_TPY_000451-0_18.xml"));
            Assert.IsTrue(result.Any(d => d.Name == "EE_FEETRA_TPY_000452-0_18.xml"));
            Assert.IsTrue(result.Any(d => d.Name == "EE_FEETRA_TPY_000454-0_18.XML"));
            Assert.IsTrue(result.Any(d => d.Name == "GG_TR_529900G3SW56SHYNPR95_01_20180316_0014_01.zip"));
        }
コード例 #2
0
        public void CopyWithExclusionFilemaskOnly()
        {
            //Arrange
            var channelSettings = new FromSettings()
            {
                Path                = "/home/ec2-user/From",
                Type                = ConfigChannelType.Sftp,
                PrivateKey          = Path.Combine("Common", "key.private"),
                Host                = "127.0.0.1",
                Port                = 22,
                UserName            = "******",
                ExclusionFileMasks  = new [] { "EE_*_*_*-0_18.xml" },
                IgnoreCaseSensitive = false
            };

            _workingDirectory.DeleteWithContentIfExists().CreateIfNotExists();

            SftpChannel sftp = new SftpChannel(_workingDirectory, channelSettings);
            //Act
            var result = sftp.Copy();

            //Assert
            Assert.IsTrue(result.Any(d => d.Name == "EE_FEETRA_TPY_000454-0_18.XML"));
            Assert.IsTrue(result.Any(d => d.Name == "GG_TR_529900G3SW56SHYNPR95_01_20180316_0014_01.zip"));

            //Assert.AreEqual(6, _from.Count());
            //Assert.IsTrue(sourceFiles.Any(d => d.Name == "EE_FEETRA_TPY_000451-0_18.xml"));
            //Assert.IsTrue(sourceFiles.Any(d => d.Name == "EE_FEETRA_TPY_000452-0_18.xml"));
            //Assert.IsTrue(sourceFiles.Any(d => d.Name == $"GG_TR_529900G3SW56SHYNPR95_01_20180316_0014_01.zip{Constants.FileExtensions.FileOps}"));
            //Assert.IsTrue(sourceFiles.Any(d => d.Name == $"EE_FEETRA_TPY_000454-0_18.XML{Constants.FileExtensions.FileOps}"));
            //Assert.IsTrue(sourceFiles.Any(d => d.Name == "EE_FEETRA_TPY_000454-0_18.XML"));
            //Assert.IsTrue(sourceFiles.Any(d => d.Name == "GG_TR_529900G3SW56SHYNPR95_01_20180316_0014_01.zip"));
        }
コード例 #3
0
        public void FilemaskSettedToDoNotFetchAnyFiles()
        {
            //Arrange
            var channelSettings = new FromSettings()
            {
                Path                = _fromFolder.FullName,
                FileMask            = "*.txt",
                ExclusionFileMasks  = new string[] { "*.XML", "*.zip" },
                Type                = ConfigChannelType.Local,
                IgnoreCaseSensitive = true
            };
            LocalChannel channel = new LocalChannel(_workingDirectory, channelSettings);

            //Act
            var result = channel.Copy();

            //Assert
            var sourceFiles = new DirectoryInfo(channelSettings.Path).GetFiles();

            Assert.AreEqual(0, result.Count());

            Assert.AreEqual(4, sourceFiles.Count());
            Assert.IsTrue(sourceFiles.Any(d => d.Name == "EE_FEETRA_TPY_000451-0_18.xml"));
            Assert.IsTrue(sourceFiles.Any(d => d.Name == "EE_FEETRA_TPY_000452-0_18.xml"));
            Assert.IsTrue(sourceFiles.Any(d => d.Name == "EE_FEETRA_TPY_000454-0_18.XML"));
            Assert.IsTrue(sourceFiles.Any(d => d.Name == "GG_TR_529900G3SW56SHYNPR95_01_20180316_0014_01.zip"));
        }
コード例 #4
0
        public void CopyByFilemaskUppercase()
        {
            //Arrange
            var channelSettings = new FromSettings()
            {
                Path                = "/home/ec2-user/From",
                Type                = ConfigChannelType.Sftp,
                PrivateKey          = Path.Combine("Common", "key.private"),
                Host                = "127.0.0.1",
                Port                = 22,
                UserName            = "******",
                FileMask            = "EE_*_*_*-0_18.xml",
                IgnoreCaseSensitive = true
            };

            _workingDirectory.DeleteWithContentIfExists().CreateIfNotExists();

            SftpChannel sftp = new SftpChannel(_workingDirectory, channelSettings);
            //Act
            var result = sftp.Copy();

            //Assert
            Assert.IsTrue(result.Any(d => d.Name == "EE_FEETRA_TPY_000451-0_18.xml"));
            Assert.IsTrue(result.Any(d => d.Name == "EE_FEETRA_TPY_000452-0_18.xml"));
            Assert.IsTrue(result.Any(d => d.Name == "EE_FEETRA_TPY_000454-0_18.XML"));
        }
コード例 #5
0
        public void CopyInboundAllFilesWithoutLocalBackup()
        {
            //Arrange
            var channelSettings = new FromSettings()
            {
                Path = _fromFolder.FullName,
                Type = ConfigChannelType.Local
            };
            LocalChannel channel = new LocalChannel(_workingDirectory, channelSettings);
            //var files = new DirectoryInfo(channelSettings.Path).GetFiles();

            //Act
            var result = channel.Copy();

            //Assert
            Assert.AreEqual(result.Count(), _testData.GetFiles().Length);
            Assert.IsTrue(result.Any(d => d.Name == "EE_FEETRA_TPY_000451-0_18.xml"));
            Assert.IsTrue(result.Any(d => d.Name == "EE_FEETRA_TPY_000452-0_18.xml"));
            Assert.IsTrue(result.Any(d => d.Name == "EE_FEETRA_TPY_000454-0_18.XML"));
            Assert.IsTrue(result.Any(d => d.Name == "GG_TR_529900G3SW56SHYNPR95_01_20180316_0014_01.zip"));

            var _fromDataFiles = _fromFolder.GetFiles();

            Assert.AreEqual(_testData.GetFiles().Length * 2, _fromFolder.GetFiles().Length);
            Assert.IsTrue(_fromDataFiles.Any(d => d.Name == $"EE_FEETRA_TPY_000451-0_18.xml{Constants.FileExtensions.FileOps}"));
            Assert.IsTrue(_fromDataFiles.Any(d => d.Name == $"EE_FEETRA_TPY_000452-0_18.xml{Constants.FileExtensions.FileOps}"));
            Assert.IsTrue(_fromDataFiles.Any(d => d.Name == $"EE_FEETRA_TPY_000454-0_18.XML{Constants.FileExtensions.FileOps}"));
            Assert.IsTrue(_fromDataFiles.Any(d => d.Name == $"GG_TR_529900G3SW56SHYNPR95_01_20180316_0014_01.zip{Constants.FileExtensions.FileOps}"));
            Assert.IsTrue(_fromDataFiles.Any(d => d.Name == "EE_FEETRA_TPY_000451-0_18.xml"));
            Assert.IsTrue(_fromDataFiles.Any(d => d.Name == "EE_FEETRA_TPY_000452-0_18.xml"));
            Assert.IsTrue(_fromDataFiles.Any(d => d.Name == "EE_FEETRA_TPY_000454-0_18.XML"));
            Assert.IsTrue(_fromDataFiles.Any(d => d.Name == "GG_TR_529900G3SW56SHYNPR95_01_20180316_0014_01.zip"));
        }
コード例 #6
0
        public void CopyWithExclusionFilemaskAndFilemask()
        {
            //Arrange
            var channelSettings = new FromSettings()
            {
                Path               = _fromFolder.FullName,
                FileMask           = "*.zip",
                ExclusionFileMasks = new string[] { "EE_*_*_*1-0_18.xml", "*.XML" },
                Type               = ConfigChannelType.Local
            };
            LocalChannel channel = new LocalChannel(_workingDirectory, channelSettings);

            //Act
            var result = channel.Copy();

            //Assert
            var sourceFiles = new DirectoryInfo(channelSettings.Path).GetFiles();

            Assert.AreEqual(1, result.Count());
            Assert.IsTrue(result.Any(d => d.Name == "GG_TR_529900G3SW56SHYNPR95_01_20180316_0014_01.zip"));

            Assert.AreEqual(5, sourceFiles.Count());
            Assert.IsTrue(sourceFiles.Any(d => d.Name == "EE_FEETRA_TPY_000451-0_18.xml"));
            Assert.IsTrue(sourceFiles.Any(d => d.Name == "EE_FEETRA_TPY_000452-0_18.xml"));
            Assert.IsTrue(sourceFiles.Any(d => d.Name == $"GG_TR_529900G3SW56SHYNPR95_01_20180316_0014_01.zip{Constants.FileExtensions.FileOps}"));
            Assert.IsTrue(sourceFiles.Any(d => d.Name == "EE_FEETRA_TPY_000454-0_18.XML"));
            Assert.IsTrue(sourceFiles.Any(d => d.Name == "GG_TR_529900G3SW56SHYNPR95_01_20180316_0014_01.zip"));
        }
コード例 #7
0
        public StepContext(IStep processingStep, Guid guid, DirectoryInfo workingDirectory, FromSettings fromSettings = null)
        {
            _fromSettings = fromSettings;

            _workingDirectory = workingDirectory;

            _guid = guid;

            _processingStep = processingStep ?? throw new ArgumentNullException($"{processingStep}");
        }
コード例 #8
0
        public void CopyAllInboundFilesTwice()
        {
            //Arrange
            var channelSettings = new FromSettings()
            {
                Path = _fromFolder.FullName,
                Type = ConfigChannelType.Local
            };
            LocalChannel channel = new LocalChannel(_workingDirectory, channelSettings);

            //Act
            var result1 = channel.Copy();
            var result2 = channel.Copy();

            //Assert
            foreach (var item in result1)
            {
                Assert.IsTrue(result2.Any(d => d.Name == item.Name));
            }
        }
コード例 #9
0
        public void CopyEmptyDirectoryFromSftp()
        {
            //Arrange
            var channelSettings = new FromSettings()
            {
                Path       = "/home/ec2-user/Empty",
                Type       = ConfigChannelType.Sftp,
                PrivateKey = Path.Combine("Common", "key.private"),
                Host       = "127.0.0.1",
                Port       = 22,
                UserName   = "******",
            };

            _workingDirectory.DeleteWithContentIfExists().CreateIfNotExists();

            SftpChannel sftp = new SftpChannel(_workingDirectory, channelSettings);
            //Act
            var result = sftp.Copy();

            //Assert
            Assert.IsTrue(!result.Any());
        }
コード例 #10
0
        public void CopyFromEmptyDirectoryFilemask()
        {
            //Arrange
            var channelSettings = new FromSettings()
            {
                Path                = _fromEmpty.FullName,
                FileMask            = "*.xml",
                ExclusionFileMasks  = new string[] {  },
                Type                = ConfigChannelType.Local,
                IgnoreCaseSensitive = true
            };

            LocalChannel channel = new LocalChannel(_workingDirectory, channelSettings);

            //Act
            var result = channel.Copy();

            //Assert
            var sourceFiles = new DirectoryInfo(channelSettings.Path).GetFiles();

            Assert.AreEqual(0, result.Count());

            Assert.AreEqual(0, sourceFiles.Count());
        }
コード例 #11
0
ファイル: From.cs プロジェクト: kuritka/ExecutiveOffice.EDT
 public From(FromSettings settings)
 {
     _settings = settings ?? throw new ArgumentNullException(nameof(settings));
 }
コード例 #12
0
 public void Attach(FromSettings fromSettings)
 {
     _fromSettings = fromSettings ?? throw new ArgumentNullException($"{nameof(FromSettings)}");
 }