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); }
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); }
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); }
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); }
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); }
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); }
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); }
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(); }
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)); }
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); }
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); }
public void VerifyImeManifestsAreReturned() { Assert.IsNotEmpty(PluginUtilities.GetPluginManifests()); this.assemblyLocationLoader.Setup(x => x.GetLocation()).Returns(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); Assert.IsEmpty(PluginUtilities.GetPluginManifests()); }
private void OnCreateSuccess(Client client, CreateSuccessPacket packet) { PluginUtilities.Delay(2000, () => { client.SendToClient( PluginUtilities.CreateNotification(client.ObjectId, 0x00F20A, "Welcome to Eris!")); }); }
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); }
public void VerifyTemporaryDirectoryExists() { var directoryInfo = PluginUtilities.GetTempDirectoryInfo(PluginName); Assert.IsNotNull(directoryInfo); Assert.IsNotNull(directoryInfo.Parent); Assert.IsTrue(directoryInfo.Parent.Exists); Assert.IsFalse(directoryInfo.Exists); }
public void MoveFileFailsWhenArgumentsNull() { var moveFileAction = new MoveFileAction() { Id = PluginUtilities.GetUniqueId() }; var result = moveFileAction.Execute(null); Assert.IsNotNull(result); Assert.IsFalse(result.Result); }
public void MoveFileFailsWhenMissingArgumentSourcePath() { var moveFileAction = new MoveFileAction() { Id = PluginUtilities.GetUniqueId(), DestinationDirectory = null }; var result = moveFileAction.Execute(null); Assert.IsNotNull(result); Assert.IsFalse(result.Result); }
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))); } } }
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); }
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); }
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); }
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(); }
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()); }
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(); }
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(); }
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); }
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()); }
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")); }
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); }