示例#1
0
        public void DownloadFileWithAppendTest()
        {
            var localWriteDir = Path.GetDirectoryName(Environment.ExpandEnvironmentVariables(LocalWorkingDir));
            FtpDownloadAction ftpDownloadAction = new FtpDownloadAction()
            {
                Id             = PluginUtilities.GetUniqueId(),
                LoggingService = ServicesContainer.ServicesProvider.GetLoggingService(nameof(FtpDownloadAction))
            };

            ftpDownloadAction.Host          = FtpTestCredentials.Host;
            ftpDownloadAction.Username      = FtpTestCredentials.User;
            ftpDownloadAction.Password      = FtpTestCredentials.Password;
            ftpDownloadAction.Port          = FtpTestCredentials.Port;
            ftpDownloadAction.DirectoryPath = LocalDownloadDir;
            ftpDownloadAction.Append        = true;

            var fileNamePath = CreateTestFile(localWriteDir);

            var actionResult = ftpDownloadAction.Execute(ArgumentCollection.New()
                                                         .WithArgument(FtpDownloadActionExecutionArgs.RemoteFilesCollection, new List <string>()
            {
                Path.GetFileName(fileNamePath)
            })
                                                         );

            Assert.IsNotNull(actionResult);
            Assert.IsTrue(actionResult.Result);

            File.AppendAllLines(Path.Combine(Environment.ExpandEnvironmentVariables(localWriteDir), fileNamePath), new List <string>()
            {
                // Environment.NewLine,
                $"{Environment.NewLine}Hello world!"
            });

            actionResult = ftpDownloadAction.Execute(ArgumentCollection.New()
                                                     .WithArgument(FtpDownloadActionExecutionArgs.RemoteFilesCollection, new List <string>()
            {
                Path.GetFileName(fileNamePath)
            })
                                                     );

            Assert.IsNotNull(actionResult);
            Assert.IsTrue(actionResult.Result);

            var fileLines = File.ReadAllLines(Path.Combine(
                                                  Environment.ExpandEnvironmentVariables(ftpDownloadAction.DirectoryPath),
                                                  Path.GetFileName(fileNamePath)));

            Assert.AreEqual(2, fileLines.Count());
        }
示例#2
0
        public void DownloadFileFromWorkingDirAndRenameTest()
        {
            var localWriteDir = Environment.ExpandEnvironmentVariables(LocalWorkingDir);
            FtpDownloadAction ftpDownloadAction = new FtpDownloadAction
            {
                Id               = PluginUtilities.GetUniqueId(),
                LoggingService   = ServicesContainer.ServicesProvider.GetLoggingService(nameof(FtpDownloadAction)),
                Host             = FtpTestCredentials.Host,
                Username         = FtpTestCredentials.User,
                Password         = FtpTestCredentials.Password,
                Port             = FtpTestCredentials.Port,
                DirectoryPath    = LocalDownloadDir,
                RemoteWorkingDir = "test"
            };

            ftpDownloadAction.RenameDownloaded        = true;
            ftpDownloadAction.RenameDownloadedNewName = "ROUTINDO_";
            var fileNamePath = CreateTestFile(localWriteDir);

            var actionResult = ftpDownloadAction.Execute(ArgumentCollection.New()
                                                         .WithArgument(FtpDownloadActionExecutionArgs.RemoteFilesCollection, new List <string>()
            {
                Path.GetFileName(fileNamePath)
            })
                                                         );

            Assert.IsNotNull(actionResult);
            Assert.IsTrue(actionResult.Result);
        }