public void ExecutionPipeline_Add_ThrowsException_WhenActivityHasEmptyHost()
        {
            //// Arrange
            var executorProviderMock          = new Mock <ExecutorProvider>();
            ExecutionPipeline pipeline        = new ExecutionPipeline(executorProviderMock.Object);
            ExecutionActivity invalidActivity = new CopyFilesActivity()
            {
                Host = new HostInfo()
            };

            //// Act
            pipeline.Add(invalidActivity);

            //// Assert
            Assert.Fail();
        }
        private void CopyFiles(CopyFilesActivity activity, string host)
        {
            try
            {
                var copyFilesScript = new ScriptWithParameters();
                copyFilesScript.Script = this.ActivityScriptMap.ExecutionScript;
                copyFilesScript.Params = new Dictionary <string, object>();
                copyFilesScript.Params.Add("sourcePath", activity.SourcePath);
                copyFilesScript.Params.Add("destinationPath", activity.DestinationPath);
                copyFilesScript.Params.Add("excludeExtensions", activity.ExcludeExtensions.ToArray());
                copyFilesScript.Params.Add("skipFolders", activity.SkipFolders.ToArray());
                copyFilesScript.Params.Add("skipFoldersIfExist", activity.SkipFoldersIfExist.ToArray());
                copyFilesScript.Params.Add("addTimeStampForFolder", activity.AddTimeStampForFolder);

                var response = _shellManager.ExecuteCommands(host, new List <ScriptWithParameters> {
                    copyFilesScript
                }, true);
                if ((response.FirstOrDefault() != null) &&
                    (response.FirstOrDefault() is Hashtable))
                {
                    //// additional details are there in the result
                    var details = response.FirstOrDefault() as Hashtable;
                    if (details.ContainsKey("DestinationPath"))
                    {
                        activity.DestinationPath = details["DestinationPath"].ToString();
                    }
                }
            }
            catch (RemoteException rEx)
            {
                logger.Error(rEx.Message);
                HandleException(rEx, activity);
            }
            catch (ApplicationException appEx)
            {
                logger.Error(appEx.Message);
                HandleException(appEx, activity);
            }
        }
        private string VerifyCopyFiles(CopyFilesActivity activity, string host)
        {
            var status = string.Empty;

            try
            {
                var verifyScript = new ScriptWithParameters();
                verifyScript.Script = this.ActivityScriptMap.VerificationScript;
                verifyScript.Params = new Dictionary <string, object>();
                verifyScript.Params.Add("destinationPath", activity.DestinationPath);
                var result = _shellManager.ExecuteCommands(host, new List <ScriptWithParameters> {
                    verifyScript
                }, true);
                status = result.FirstOrDefault() != null ? result[0].ToString() : "0";
            }
            catch (ApplicationException appEx)
            {
                logger.Error(appEx.Message);
                HandleException(appEx, activity);
            }

            return(status);
        }
        private bool ContainsParamsFromActivity(ScriptWithParameters scriptWithParams, CopyFilesActivity copyFilesActivity)
        {
            var parameters = scriptWithParams.Params;
            var skipFoldersIfExistParam = parameters["skipFoldersIfExist"] as string[];
            var skipFoldersParam        = parameters["skipFolders"] as string[];
            var excludeExtensionsParam  = parameters["excludeExtensions"] as string[];

            return
                (copyFilesActivity.SourcePath.Equals(parameters["sourcePath"].ToString(), StringComparison.CurrentCultureIgnoreCase) &&
                 copyFilesActivity.SkipFoldersIfExist.All(f => skipFoldersIfExistParam.Contains(f)) &&
                 copyFilesActivity.SkipFolders.All(f => skipFoldersParam.Contains(f)) &&
                 copyFilesActivity.ExcludeExtensions.All(f => excludeExtensionsParam.Contains(f)) &&
                 copyFilesActivity.DestinationPath.Equals(parameters["destinationPath"].ToString(), StringComparison.CurrentCultureIgnoreCase) &&
                 copyFilesActivity.AddTimeStampForFolder == (bool)parameters["addTimeStampForFolder"] &&
                 !string.IsNullOrWhiteSpace(scriptWithParams.Script) &&
                 parameters.Count == 6);
        }
        private bool VerifyContainsParamsFromActivity(ScriptWithParameters scriptWithParams, CopyFilesActivity copyFilesActivity)
        {
            var parameters = scriptWithParams.Params;

            return(copyFilesActivity.DestinationPath.Equals(parameters["destinationPath"].ToString(), StringComparison.CurrentCultureIgnoreCase) &&
                   !string.IsNullOrWhiteSpace(scriptWithParams.Script) &&
                   parameters.Count == 1);
        }
Пример #6
0
        public void TestSwedishCodeActivitiesCreation()
        {
            // CheckFreeDiskSpaceActivity
            CheckFreeDiskSpaceActivity newCheckFreeDiskSpaceActivity = new CheckFreeDiskSpaceActivity();

            Assert.IsInstanceOfType(newCheckFreeDiskSpaceActivity, typeof(CheckFreeDiskSpaceActivity));

            // CopyFilesActivity
            CopyFilesActivity newCopyFilesActivity = new CopyFilesActivity();

            Assert.IsInstanceOfType(newCopyFilesActivity, typeof(CopyFilesActivity));

            // CopyImagesAndLibrariesActivity
            CopyImagesAndLibrariesActivity newCopyImagesAndLibrariesActivity = new CopyImagesAndLibrariesActivity();

            Assert.IsInstanceOfType(newCopyImagesAndLibrariesActivity, typeof(CopyImagesAndLibrariesActivity));

            // UtcDateTimeActivity
            UtcDateTimeActivity newDateTimeActivity = new UtcDateTimeActivity();

            Assert.IsInstanceOfType(newDateTimeActivity, typeof(UtcDateTimeActivity));

            // DumpProcessThreadsActivity
            DumpProcessThreadsActivity newDumpProcessThreadsActivity = new DumpProcessThreadsActivity();

            Assert.IsInstanceOfType(newDumpProcessThreadsActivity, typeof(DumpProcessThreadsActivity));

            // FileExistsActivity
            CheckIfFileExistsActivity newFileExistsActivity = new CheckIfFileExistsActivity();

            Assert.IsInstanceOfType(newFileExistsActivity, typeof(CheckIfFileExistsActivity));

            // ForceBlueScreenActivity
            ForceBlueScreenActivity newForceBlueScreenActivity = new ForceBlueScreenActivity();

            Assert.IsInstanceOfType(newForceBlueScreenActivity, typeof(ForceBlueScreenActivity));

            // GetCurrentLoggedOnUsersActivity
            GetCurrentLoggedOnUsersActivity newGetLoggedOnUsersActivity = new GetCurrentLoggedOnUsersActivity();

            Assert.IsInstanceOfType(newGetLoggedOnUsersActivity, typeof(GetCurrentLoggedOnUsersActivity));

            // GetOsFileVersionActivity
            GetOsFileVersionActivity newGetOsFileVersionActivity = new GetOsFileVersionActivity();

            Assert.IsInstanceOfType(newGetOsFileVersionActivity, typeof(GetOsFileVersionActivity));

            // GetProcessIdsActivity
            GetProcessIdsActivity newGetProcessIdActivity = new GetProcessIdsActivity();

            Assert.IsInstanceOfType(newGetProcessIdActivity, typeof(GetProcessIdsActivity));

            // GetSystemUptimeActivity
            GetSystemUptimeActivity newGetSystemUptimeActivity = new GetSystemUptimeActivity();

            Assert.IsInstanceOfType(newGetSystemUptimeActivity, typeof(GetSystemUptimeActivity));

            // GetSystemTimeSkewActivity
            GetSystemTimeSkewActivity newGetTimeSkewActivity = new GetSystemTimeSkewActivity();

            Assert.IsInstanceOfType(newGetTimeSkewActivity, typeof(GetSystemTimeSkewActivity));

            // GetWindowsEventsActivity
            GetWindowsEventsActivity newGetWindowsEventsActivity = new GetWindowsEventsActivity();

            Assert.IsInstanceOfType(newGetWindowsEventsActivity, typeof(GetWindowsEventsActivity));

            // InstallSysInternalsActivity
            InstallSysInternalsActivity newInstallSysInternalsActivity = new InstallSysInternalsActivity();

            Assert.IsInstanceOfType(newInstallSysInternalsActivity, typeof(InstallSysInternalsActivity));

            // EditConfigurationFileActivity
            EditConfigurationFileActivity newModifyConfigurationFileActivity = new EditConfigurationFileActivity();

            Assert.IsInstanceOfType(newModifyConfigurationFileActivity, typeof(EditConfigurationFileActivity));

            // PingResponseActivity
            PingResponseActivity newPingActivity = new PingResponseActivity();

            Assert.IsInstanceOfType(newPingActivity, typeof(PingResponseActivity));

            // PortConnectivityActivity
            PortConnectivityActivity newPortConnectivityActivity = new PortConnectivityActivity();

            Assert.IsInstanceOfType(newPortConnectivityActivity, typeof(PortConnectivityActivity));

            // ReadFileContentsActivity
            ReadFileContentsActivity newReadFileContentsActivity = new ReadFileContentsActivity();

            Assert.IsInstanceOfType(newReadFileContentsActivity, typeof(ReadFileContentsActivity));

            // RenameMachineActivity
            RenameMachineActivity newRenameMachineActivity = new RenameMachineActivity();

            Assert.IsInstanceOfType(newRenameMachineActivity, typeof(RenameMachineActivity));

            // RestartServiceActivity
            RestartServiceActivity newRestartServiceActivity = new RestartServiceActivity();

            Assert.IsInstanceOfType(newRestartServiceActivity, typeof(RestartServiceActivity));

            // SetSymbolServerEnvironmentPathActivity
            SetSymbolServerEnvironmentPathActivity newSetSymbolsEnvironmentPath = new SetSymbolServerEnvironmentPathActivity();

            Assert.IsInstanceOfType(newSetSymbolsEnvironmentPath, typeof(SetSymbolServerEnvironmentPathActivity));

            // StartSecureDeleteActivity
            StartSecureDeleteActivity newStartSecureDeleteActivity = new StartSecureDeleteActivity();

            Assert.IsInstanceOfType(newStartSecureDeleteActivity, typeof(StartSecureDeleteActivity));

            // WebStringActivity
            WebStringActivity neWebStringActivity = new WebStringActivity();

            Assert.IsInstanceOfType(neWebStringActivity, typeof(WebStringActivity));

            // WindowsUpdateActivity
            WindowsUpdateActivity newWindowsUpdateActivity = new WindowsUpdateActivity();

            Assert.IsInstanceOfType(newWindowsUpdateActivity, typeof(WindowsUpdateActivity));
        }