Exemplo n.º 1
0
        public void WatchForFilesTest()
        {
            string     remoteWorkingDir = "/";
            FtpWatcher watcher          = new FtpWatcher
            {
                Id             = PluginUtilities.GetUniqueId(),
                LoggingService = ServicesContainer.ServicesProvider.GetLoggingService(nameof(FtpWatcher)),
                Host           = FtpTestCredentials.Host,
                Username       = FtpTestCredentials.User,
                Password       = FtpTestCredentials.Password,
                SelectFiles    = true
            };


            var localWriteDir = Environment.ExpandEnvironmentVariables(LocalWorkingDir);
            var fileNamePath  = CreateTestFile(localWriteDir);
            var watcherResult = watcher.Watch();

            Assert.IsNotNull(watcherResult);
            Assert.AreEqual(true, watcherResult.Result);
            Assert.IsNotNull(watcherResult.WatchingArguments);
            Assert.IsTrue(watcherResult.WatchingArguments.HasArgument(FtpWatcherResultArgs.RemoteFilesCollection));
            Assert.IsTrue(watcherResult.WatchingArguments.GetValue <List <string> >(FtpWatcherResultArgs.RemoteFilesCollection).Any());
            Assert.AreEqual(1, watcherResult.WatchingArguments.GetValue <List <string> >(FtpWatcherResultArgs.RemoteFilesCollection).Count);

            var watchedFile = watcherResult.WatchingArguments.GetValue <List <string> >(FtpWatcherResultArgs
                                                                                        .RemoteFilesCollection).Single();

            Assert.AreEqual(remoteWorkingDir + Path.GetFileName(fileNamePath), watchedFile);
        }
Exemplo n.º 2
0
        public void WatchForFilesByPatternTest()
        {
            string     remoteWorkingDir = "/test";
            FtpWatcher watcher          = new FtpWatcher
            {
                Id               = PluginUtilities.GetUniqueId(),
                LoggingService   = ServicesContainer.ServicesProvider.GetLoggingService(nameof(FtpWatcher)),
                Host             = FtpTestCredentials.Host,
                Username         = FtpTestCredentials.User,
                Password         = FtpTestCredentials.Password,
                Port             = FtpTestCredentials.Port,
                RemoteWorkingDir = remoteWorkingDir,
                SelectFiles      = true
            };

            watcher.SearchPattern = "prefix*.pat";

            var localWriteDir     = Path.Combine(Environment.ExpandEnvironmentVariables(LocalWorkingDir), remoteWorkingDir.Trim('/'));
            var fileNamePath      = CreateTestFile(localWriteDir, "prefix", "pat");
            var otherFileNamePath = CreateTestFile(localWriteDir);
            var watcherResult     = watcher.Watch();

            Assert.IsNotNull(watcherResult);
            Assert.AreEqual(true, watcherResult.Result);
            Assert.IsNotNull(watcherResult.WatchingArguments);
            Assert.IsTrue(watcherResult.WatchingArguments.HasArgument(FtpWatcherResultArgs.RemoteFilesCollection));
            Assert.IsTrue(watcherResult.WatchingArguments.GetValue <List <string> >(FtpWatcherResultArgs.RemoteFilesCollection).Any());
            Assert.AreEqual(1, watcherResult.WatchingArguments.GetValue <List <string> >(FtpWatcherResultArgs.RemoteFilesCollection).Count);

            var watchedFile = watcherResult.WatchingArguments.GetValue <List <string> >(FtpWatcherResultArgs
                                                                                        .RemoteFilesCollection).Single();

            Assert.AreEqual(UriHelper.BuildPath("/", remoteWorkingDir, Path.GetFileName(fileNamePath)), watchedFile);
        }
Exemplo n.º 3
0
        public void WatchForDirectoryTest()
        {
            string     remoteWorkingDir = "/";
            FtpWatcher watcher          = new FtpWatcher
            {
                Id                = PluginUtilities.GetUniqueId(),
                LoggingService    = ServicesContainer.ServicesProvider.GetLoggingService(nameof(FtpWatcher)),
                Host              = FtpTestCredentials.Host,
                Username          = FtpTestCredentials.User,
                Password          = FtpTestCredentials.Password,
                SelectDirectories = true
            };


            var watcherResult = watcher.Watch();

            Assert.IsNotNull(watcherResult);
            Assert.AreEqual(true, watcherResult.Result);
            Assert.IsNotNull(watcherResult.WatchingArguments);
            Assert.IsTrue(watcherResult.WatchingArguments.HasArgument(FtpWatcherResultArgs.RemoteFilesCollection));
            Assert.IsTrue(watcherResult.WatchingArguments.GetValue <List <string> >(FtpWatcherResultArgs.RemoteFilesCollection).Any());
            Assert.AreEqual(1, watcherResult.WatchingArguments.GetValue <List <string> >(FtpWatcherResultArgs.RemoteFilesCollection).Count);
        }