Ejemplo n.º 1
0
        public void DeleteFilesTest()
        {
            var             localWriteDir   = Path.GetDirectoryName(Environment.ExpandEnvironmentVariables(LocalWorkingDir));
            FtpDeleteAction ftpDeleteAction = new FtpDeleteAction()
            {
                Id             = PluginUtilities.GetUniqueId(),
                LoggingService = ServicesContainer.ServicesProvider.GetLoggingService(nameof(FtpDownloadAction))
            };

            ftpDeleteAction.Host             = FtpTestCredentials.Host;
            ftpDeleteAction.Username         = FtpTestCredentials.User;
            ftpDeleteAction.Password         = FtpTestCredentials.Password;
            ftpDeleteAction.Port             = FtpTestCredentials.Port;
            ftpDeleteAction.RemoteWorkingDir = "/";

            var fileNamePath = CreateTestFile(localWriteDir);

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

            Assert.IsNotNull(actionResult);
            Assert.IsTrue(actionResult.Result);
        }
Ejemplo n.º 2
0
        public void KillProcessByNameFromExecutionArgsTest()
        {
            var processId = StartNotepad();
            Assert.AreNotEqual(0, processId);
            Console.WriteLine($"Created Process with ID {processId}");
            Thread.Sleep(1000);
            KillProcessByNameAction action = new KillProcessByNameAction()
            {
                Id = PluginUtilities.GetUniqueId(),
                LoggingService = ServicesContainer.ServicesProvider.GetLoggingService(nameof(KillProcessByNameAction)),
            };

            var actionResult = action.Execute(ArgumentCollection.New()
                .WithArgument(KillProcessByNameActionExecutionArgs.ProcessName, "notepad")
            );
            Assert.IsNotNull(actionResult);
            Assert.IsTrue(actionResult.Result);
            Assert.IsTrue(
                actionResult.AdditionalInformation.HasArgument(KillProcessActionResultArgs
                    .ProcessesKilledSuccessfully));
            Assert.AreEqual(1,
                actionResult.AdditionalInformation
                    .GetValue<List<int>>(KillProcessActionResultArgs.ProcessesKilledSuccessfully).Count);
            Assert.AreEqual(processId,
                actionResult.AdditionalInformation
                    .GetValue<List<int>>(KillProcessActionResultArgs.ProcessesKilledSuccessfully).Single());
            Thread.Sleep(2000);
            actionResult = action.Execute(ArgumentCollection.New()
                .WithArgument(KillProcessByNameActionExecutionArgs.ProcessName, "notepad")
            );
            Assert.IsNotNull(actionResult);
            Assert.IsFalse(actionResult.Result);
        }
Ejemplo n.º 3
0
        public void CreateZipOnSameExistingOptionTest()
        {
            var     outputDirectory = Path.GetTempPath();
            IAction action          = new ZipDirectoryAction()
            {
                EraseOutputIfExists = true,
                UseLocationAsOutput = true,
                Id             = PluginUtilities.GetUniqueId(),
                LoggingService = ServicesContainer.ServicesProvider.GetLoggingService(null)
            };

            var testDir = Path.Combine(Path.GetTempPath(), "TEMPO_TEST");

            if (!Directory.Exists(testDir))
            {
                Directory.CreateDirectory(testDir);
            }

            File.WriteAllText(Path.Combine(outputDirectory, "TEMPO_TEST.zip"), "");

            var actionResult = action.Execute(ArgumentCollection.New()
                                              .WithArgument(ZipDirectoryActionExecutionArgs.Directory, testDir));

            Assert.IsNotNull(actionResult);
            Assert.IsTrue(actionResult.Result);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public void SendSampleFileTest()
        {
            FtpUploadAction action = new FtpUploadAction()
            {
                Id                          = PluginUtilities.GetUniqueId(),
                LoggingService              = ServicesContainer.ServicesProvider.GetLoggingService(nameof(FtpUploadAction)),
                Host                        = FtpTestCredentials.Host,
                Username                    = FtpTestCredentials.User,
                Password                    = FtpTestCredentials.Password,
                Port                        = FtpTestCredentials.Port,
                DestinationFolderPath       = "Data",
                DestinationFileName         = "renamed.txt",
                UseRemoteTemporaryExtension = true,
                RemoteTemporaryExtension    = "remote",
                UseLocalTemporaryExtension  = true,
                LocalTemporaryExtension     = "local",
                Overwrite                   = true,
                CreateRemoteDirectory       = true
            };

            string sourceFileName = Path.Combine(Path.GetTempPath(), "test.txt");

            File.WriteAllText(sourceFileName, "Hello world! This is a remote message!");

            var result = action.Execute(ArgumentCollection.New()
                                        .WithArgument(FtpUploadActionExecutionArgs.SourceFilesCollection, new List <string> {
                sourceFileName
            }));

            Console.WriteLine(result.AttachedException);
            Assert.IsTrue(result.Result);
            File.Delete(sourceFileName);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        public void WatchProcessNotepadTest()
        {
            IWatcher watcher = new ProcessWatcher()
            {
                Id             = PluginUtilities.GetUniqueId(),
                LoggingService = ServicesContainer.ServicesProvider.GetLoggingService(nameof(ProcessWatcher)),
                ProcessName    = "notepad"
            };

            var watcherResult = watcher.Watch();

            Assert.IsNotNull(watcherResult);
            Assert.IsFalse(watcherResult.Result);

            var process = System.Diagnostics.Process.Start("notepad");

            Assert.IsNotNull(process);
            Thread.Sleep(1000);

            watcherResult = watcher.Watch();
            Assert.IsNotNull(watcherResult);
            Assert.IsTrue(watcherResult.Result);
            Assert.IsTrue(watcherResult.WatchingArguments.HasArgument(ProcessWatcherResultArgs.ProcessName));
            Assert.IsTrue(watcherResult.WatchingArguments.HasArgument(ProcessWatcherResultArgs.ProcessId));
            Assert.AreEqual(process.ProcessName, watcherResult.WatchingArguments.GetValue <string>(ProcessWatcherResultArgs.ProcessName));
            Assert.AreEqual(process.Id, watcherResult.WatchingArguments.GetValue <int>(ProcessWatcherResultArgs.ProcessId));

            process.Kill();
        }
Ejemplo n.º 9
0
        public void MoveFileFailsWhenUsedByAnotherProcess()
        {
            var destinationPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            var moveFileAction  = new MoveFileAction()
            {
                Id = PluginUtilities.GetUniqueId(),
                DestinationDirectory = destinationPath
            };
            var sourcePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());


            var createdFileStream = File.Create(sourcePath);

            Assert.IsTrue(File.Exists(sourcePath));
            var args   = new ArgumentCollection((MoveFileActionExecutionArgs.SourceFilePaths, sourcePath));
            var result = moveFileAction.Execute(args);

            Assert.IsNotNull(result);
            Assert.IsFalse(result.Result);

            Assert.IsTrue(File.Exists(sourcePath));
            createdFileStream.Close();

            // Cleanup
            File.Delete(sourcePath);
            Assert.IsFalse(File.Exists(sourcePath));
        }
Ejemplo n.º 10
0
        public void MoveFileTestSuccess()
        {
            var destinationPath = Path.Combine(Path.GetTempPath());
            var moveFileAction  = new MoveFileAction()
            {
                Id = PluginUtilities.GetUniqueId(),
                DestinationDirectory = destinationPath,
                DestinationPrefix    = "RENAMED"
            };
            var sourcePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            using (var file = File.Create(sourcePath))
            {
            }

            Assert.IsTrue(File.Exists(sourcePath));
            Assert.IsFalse(File.Exists(destinationPath));
            var args = new ArgumentCollection((MoveFileActionExecutionArgs.SourceFilePaths, new List <string>()
            {
                sourcePath
            }));

            var result = moveFileAction.Execute(args);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Result);
            Assert.IsFalse(File.Exists(sourcePath));
            destinationPath = Path.Combine(destinationPath, $"RENAMED{Path.GetFileName(sourcePath)}");
            Assert.IsTrue(File.Exists(destinationPath));

            // CleanUp
            File.Delete(destinationPath);
        }
Ejemplo n.º 11
0
        public void MoveFileFailsWhenDestinationFileAlreadyExist()
        {
            var destinationPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            var moveFileAction  = new MoveFileAction()
            {
                Id = PluginUtilities.GetUniqueId(),
                DestinationDirectory = destinationPath
            };
            var filePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            using (var sourceFile = File.Create(filePath))
            {
            }

            using (var destinationFile = File.Create(destinationPath))
            {
            }

            var args = new ArgumentCollection((MoveFileActionExecutionArgs.SourceFilePaths, filePath)
                                              );

            var result = moveFileAction.Execute(args);

            Assert.IsNotNull(result);
            Assert.IsFalse(result.Result);

            // Clean up
            File.Delete(filePath);
            File.Delete(destinationPath);
        }
Ejemplo n.º 12
0
        public void VerifyImeManifestsAreReturned()
        {
            Assert.IsNotEmpty(PluginUtilities.GetPluginManifests());

            this.assemblyLocationLoader.Setup(x => x.GetLocation()).Returns(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            Assert.IsEmpty(PluginUtilities.GetPluginManifests());
        }
Ejemplo n.º 13
0
 private void OnCreateSuccess(Client client, CreateSuccessPacket packet)
 {
     PluginUtilities.Delay(2000,
                           () => {
         client.SendToClient(
             PluginUtilities.CreateNotification(client.ObjectId, 0x00F20A, "Welcome to Eris!"));
     });
 }
Ejemplo n.º 14
0
        public void GetUniqueIdTest()
        {
            var uniqueId          = PluginUtilities.GetUniqueId();
            var upperCaseUniqueId = uniqueId.ToUpper();

            Assert.IsFalse(string.IsNullOrWhiteSpace(uniqueId));
            // Assert unique Id is generated in upper cases
            Assert.AreEqual(uniqueId, upperCaseUniqueId);
        }
Ejemplo n.º 15
0
        public void VerifyTemporaryDirectoryExists()
        {
            var directoryInfo = PluginUtilities.GetTempDirectoryInfo(PluginName);

            Assert.IsNotNull(directoryInfo);
            Assert.IsNotNull(directoryInfo.Parent);
            Assert.IsTrue(directoryInfo.Parent.Exists);
            Assert.IsFalse(directoryInfo.Exists);
        }
Ejemplo n.º 16
0
        public void MoveFileFailsWhenArgumentsNull()
        {
            var moveFileAction = new MoveFileAction()
            {
                Id = PluginUtilities.GetUniqueId()
            };
            var result = moveFileAction.Execute(null);

            Assert.IsNotNull(result);
            Assert.IsFalse(result.Result);
        }
Ejemplo n.º 17
0
        public void MoveFileFailsWhenMissingArgumentSourcePath()
        {
            var moveFileAction = new MoveFileAction()
            {
                Id = PluginUtilities.GetUniqueId(),
                DestinationDirectory = null
            };
            var result = moveFileAction.Execute(null);

            Assert.IsNotNull(result);
            Assert.IsFalse(result.Result);
        }
Ejemplo n.º 18
0
        public void MoveFileFailsWhenMissingArgumentDestinationPath()
        {
            var moveFileAction = new MoveFileAction()
            {
                Id = PluginUtilities.GetUniqueId()
            };
            var args   = new ArgumentCollection((MoveFileActionExecutionArgs.SourceFilePaths, ""));
            var result = moveFileAction.Execute(args);

            Assert.IsNotNull(result);
            Assert.IsFalse(result.Result);
        }
        /// <summary>
        /// Populates the list of modules
        /// </summary>
        private void PopulateModuleList()
        {
            if (this.AppSettingsService != null)
            {
                var disabledPlugins = this.AppSettingsService.AppSettings.DisabledPlugins;
                var presentPlugins  = PluginUtilities.GetPluginManifests();

                foreach (var pluginSetting in presentPlugins)
                {
                    this.Plugins.Add(new PluginRowViewModel(pluginSetting, disabledPlugins.All(p => p != pluginSetting.ProjectGuid)));
                }
            }
        }
Ejemplo n.º 20
0
        public void CreateWatcherInfoTest()
        {
            var    id              = PluginUtilities.GetUniqueId();
            string name            = "watcherName";
            string description     = "This is watcher description";
            var    watcherInstance = RoutindoWatcherInfo.Create <WatcherMock>(id, name, description);

            Assert.IsNotNull(watcherInstance);
            Assert.AreEqual(id, watcherInstance.Id);
            Assert.AreEqual(name, watcherInstance.Name);
            Assert.AreEqual(description, watcherInstance.Description);
            Assert.AreEqual(typeof(WatcherMock), watcherInstance.ComponentType);
        }
Ejemplo n.º 21
0
        public void CreateArgumentMapperInfoTest()
        {
            var    id                = PluginUtilities.GetUniqueId();
            string name              = "ComponentName";
            string description       = "This is Component description";
            var    componentInstance = RoutindoArgumentsMapperInfo.Create <ArgumentMapperMock>(id, name, description);

            Assert.IsNotNull(componentInstance);
            Assert.AreEqual(id, componentInstance.Id);
            Assert.AreEqual(name, componentInstance.Name);
            Assert.AreEqual(description, componentInstance.Description);
            Assert.AreEqual(typeof(ArgumentMapperMock), componentInstance.ComponentType);
        }
Ejemplo n.º 22
0
        public void CreateActionInfoTest()
        {
            var    id             = PluginUtilities.GetUniqueId();
            string name           = "actionName";
            string description    = "This is action description";
            var    actionInstance = RoutindoActionInfo.Create <ActionMock>(id, name, description);

            Assert.IsNotNull(actionInstance);
            Assert.AreEqual(id, actionInstance.Id);
            Assert.AreEqual(name, actionInstance.Name);
            Assert.AreEqual(description, actionInstance.Description);
            Assert.AreEqual(typeof(ActionMock), actionInstance.ComponentType);
        }
Ejemplo n.º 23
0
    public override void DoUpdate()
    {
        if (!IsSocketValid())
        {
            return;
        }
        removeKey = null;
        clearBool = false;
        PluginUtilities.ProfilerBegin("NetManager.DoUpdate");
        foreach (var e in timeoutPacket.Keys)
        {
            timeoutPacket[e].remainTime -= Time.unscaledDeltaTime;
            if (timeoutPacket[e].remainTime <= 0)
            {
                if (OnProcessTimeout(e, timeoutPacket[e]))
                {
                    clearBool = true;
                    break;
                }
                else
                {
                    removeKey = e;
                    break;
                }
            }
        }

        if (clearBool)
        {
            timeoutPacket.Clear();
        }
        else if (removeKey != null)
        {
            timeoutPacket.Remove(removeKey.Value);
        }

        NetPacket packet = null;

        while ((packet = recvPool.GetRecvPacket()) != null)
        {
            if (LaunchConfigManager.LogEnable("NetManager"))
            {
                //LogUtils.LogWarning("Net recv, cmd =", packet.msgid, "len = ", packet.data.Length);
            }

            DispatchCmdEvent(packet);
        }

        PluginUtilities.ProfilerEnd();
    }
Ejemplo n.º 24
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());
        }
Ejemplo n.º 25
0
 public override void DoUpdate()
 {
     PluginUtilities.ProfilerBegin("NetServerManager.DoUpdate");
     foreach (var e in servers)
     {
         if (!e.Value.IsSocketValid())
         {
             OnConnectionChange(e.Value, false);
             servers.Remove(e.Key);
             break;
         }
     }
     PluginUtilities.ProfilerEnd();
 }
Ejemplo n.º 26
0
 public override void DoUpdate()
 {
     PluginUtilities.ProfilerBegin("ConroutineManager.DoUpdate");
     for (int i = 0; i < coroutineList.Count; i++)
     {
         var c = coroutineList[i];
         c.DoUpdate();
         if (c.IsFinish && coroutineList.IndexOf(c) != -1)
         {
             coroutineList.RemoveAt(i);
             i--;
         }
     }
     PluginUtilities.ProfilerEnd();
 }
Ejemplo n.º 27
0
        private static List <PluginDefinition> GetPluginDefinitionsToRun()
        {
            List <PluginDefinition> results = new List <PluginDefinition>();
            var plugins = PluginUtilities.GetAvailablePluginsFromAppSettings("PluginAssemblies");

            if (!string.IsNullOrWhiteSpace(PluginsToRun))
            {
                var targetPlugins = PluginsToRun.ToList(';');
                results.AddRange(
                    from r in plugins where targetPlugins.Contains(r.Type.Name) select r
                    );
            }

            return(results);
        }
Ejemplo n.º 28
0
        public void WatchProcessFailsOnNoNameTest()
        {
            IWatcher watcher = new ProcessWatcher()
            {
                Id             = PluginUtilities.GetUniqueId(),
                LoggingService = ServicesContainer.ServicesProvider.GetLoggingService(nameof(ProcessWatcher)),
            };

            var watcherResult = watcher.Watch();

            Assert.IsNotNull(watcherResult);
            Assert.IsFalse(watcherResult.Result);
            Assert.IsNotNull(watcherResult.AttachedException);
            Assert.AreEqual(typeof(MissingArgumentException), watcherResult.AttachedException.GetType());
        }
Ejemplo n.º 29
0
        public void CreateZipFromDirectoryTest()
        {
            var     outputDirectory = Path.Combine(Path.GetTempPath(), "TEST_OUTPUT");
            IAction action          = new ZipDirectoryAction()
            {
                OutputDirectory       = outputDirectory,
                CreateOutputDirectory = true,
                EraseOutputIfExists   = true,
                Id = PluginUtilities.GetUniqueId(), LoggingService = ServicesContainer.ServicesProvider.GetLoggingService(null)
            };

            var testDir = Path.Combine(Path.GetTempPath(), "TEMPO_TEST");

            if (!Directory.Exists(testDir))
            {
                Directory.CreateDirectory(testDir);
            }

            var createdDir = new DirectoryInfo(testDir);

            Assert.IsTrue(Directory.Exists(createdDir.FullName));
            var file1 = Path.Combine(createdDir.FullName, "file1.txt");

            if (!File.Exists(file1))
            {
                File.WriteAllText(file1, "Hello world");
            }
            Assert.IsTrue(File.Exists(file1));
            var file2 = Path.Combine(createdDir.FullName, "file2.txt");

            if (!File.Exists(file2))
            {
                File.WriteAllText(file2, "Hello world");
            }
            Assert.IsTrue(File.Exists(file2));

            var actionResult = action.Execute(ArgumentCollection.New()
                                              .WithArgument(ZipDirectoryActionExecutionArgs.Directory, createdDir.FullName));

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

            Assert.IsTrue(File.Exists(Path.Combine(outputDirectory, "TEMPO_TEST.zip")));

            Directory.Delete(createdDir.FullName, true);

            File.Delete(Path.Combine(Path.GetTempPath(), "TEMPO_TEST.zip"));
        }
Ejemplo n.º 30
0
        public void VerifyPluginDirectoryExistsWorks()
        {
            var directoryInfo = PluginUtilities.PluginDirectoryExists(out var specificPluginFolderExists);

#if DEBUG
            Assert.IsTrue(specificPluginFolderExists);
            Assert.IsTrue(directoryInfo.FullName.EndsWith(PluginUtilities.PluginDirectoryName));
#else
            Assert.IsFalse(specificPluginFolderExists);
            Assert.IsFalse(directoryInfo.FullName.EndsWith(PluginUtilities.PluginDirectoryName));
#endif
            this.assemblyLocationLoader.Setup(x => x.GetLocation()).Returns(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
            directoryInfo = PluginUtilities.PluginDirectoryExists(out specificPluginFolderExists);
            Assert.IsFalse(specificPluginFolderExists);
            Assert.AreEqual(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), directoryInfo.FullName);
        }