Exemple #1
0
        public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
        {
            IParameter IPfile = testAction.GetParameter("File", false, new[] { ActionMode.Input });
            IParameter IPinverse = testAction.GetParameter("Exists", false, new[] { ActionMode.Input });

            string file = IPfile.GetAsInputValue().Value;
            string inverseString = IPinverse.GetAsInputValue().Value;

            bool fileExists; // if this is true, the file should exists. Default value should be true
            bool result;

            bool success = Boolean.TryParse(inverseString, out fileExists);
            if (!success)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Failed, "Inverse has to be an boolean");
                return;
            }

            if (FileOrDirectoryExists(file))
            {
                result = fileExists; //if the file is found, the value of fileExists will be returned.
            }
            else
            {
                result = !fileExists; //if the file is not found, the inverse of fileExists will be returned.
            }

            if (result)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Ok, "Correct");
                return;
            }

            testAction.SetResult(SpecialExecutionTaskResultState.Failed, "Incorrect");
        }
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            String paraSettingsFile = testAction.GetParameterAsInputValue("File", false).Value;

            if (string.IsNullOrEmpty(paraSettingsFile))
            {
                throw new ArgumentException(string.Format("Es muss eine Settingsdatei (File) angegeben sein."));
            }

            if (!Collections.Instance.CollectionExists(BufferCollectionPath))
            {
                throw new InvalidOperationException("Es existiert keine Buffer-Collection in den Einstellungen!");
            }

            XmlDocument doc = new XmlDocument();

            doc.Load(paraSettingsFile);

            XmlNode     SettingsListNode = doc.SelectSingleNode("/root");
            XmlNodeList SettingsNodeList = SettingsListNode.SelectNodes("CollectionEntry");

            foreach (XmlNode node in SettingsNodeList)
            {
                string key   = node.Attributes.GetNamedItem("name").Value;
                string value = node.InnerText;
                Buffers.Instance.SetBuffer(key, value, false);
            }

            return(new PassedActionResult("settings loaded from : " + paraSettingsFile));
        }
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            String endPoint       = testAction.GetParameterAsInputValue("EndPoint", false).Value;
            String repositoryName = testAction.GetParameterAsInputValue("Repository", false).Value;

            if (string.IsNullOrEmpty(endPoint))
            {
                throw new ArgumentException("End Point is a mandatory parameter.");
            }
            else
            {
                if (!endPoint.EndsWith("/"))
                {
                    endPoint += "/";
                }
            }

            if (string.IsNullOrEmpty(repositoryName))
            {
                throw new ArgumentException("Repository Name is a mandatory parameter.");
            }

            var client  = new RestClient(new Uri(endPoint + "configuration/repositories/" + repositoryName));
            var request = new RestRequest(Method.DELETE);

            IRestResponse  response      = client.Execute(request);
            HttpStatusCode statusMessage = response.StatusCode;
            int            statusCode    = (int)statusMessage;

            return(new PassedActionResult("Got response: " + statusCode + " " + statusMessage));
        }
Exemple #4
0
        public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
        {
            IParameter expectedFilePathParameter = testAction.GetParameter("ExpectedFile", false, new[] { ActionMode.Input });
            IParameter actualFilePathParameter   = testAction.GetParameter("ActualFile", false, new[] { ActionMode.Input });

            string expectedFilePath = Environment.ExpandEnvironmentVariables(expectedFilePathParameter.GetAsInputValue().Value);
            string actualFilePath   = Environment.ExpandEnvironmentVariables(actualFilePathParameter.GetAsInputValue().Value);
            string result           = String.Empty;

            try
            {
                result = FileComparer.Compare(expectedFilePath, actualFilePath);
            }
            catch (FileNotFoundException exc)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Failed, exc.Message);
                return;
            }

            if (result == String.Empty)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Ok, "The contents of the files are identical.");
            }
            else
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Failed, result);
            }
        }
Exemple #5
0
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            String paraBuffer = testAction.GetParameterAsInputValue("Directory", false).Value;

            if (string.IsNullOrEmpty(paraBuffer))
            {
                throw new ArgumentException(string.Format("Es muss ein Verzeichnis angegeben sein."));
            }

            int countFiles = 0;

            if (Directory.Exists(paraBuffer))
            {
                string [] fileEntries = Directory.GetFiles(paraBuffer);
                foreach (string fileName in fileEntries)
                {
                    File.Delete(fileName);
                    countFiles++;
                }
            }
            else
            {
                throw new ArgumentException(string.Format("Es wurde kein Verzeichnis angegeben."));
            }

            return(new PassedActionResult(string.Format("Removed files: {0}", countFiles)));
        }
Exemple #6
0
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            var        action     = testAction as SpecialExecutionTaskTestAction;
            var        module     = action.TCItem.GetModule();
            XModule    xMod       = module as XModule;
            var        xParams    = xMod.GetXParams();
            ModuleType moduleType = ModuleType.Method;
            //if (!Enum.TryParse(xParams.Single(x => x.Name.ToLower() == "type").Value, out moduleType))
            //{
            //    throw new InvalidOperationException("Invalid value in 'Type' Technical Parameter");
            //}

            ReflectionConfig config = new ReflectionConfig
            {
                ClassName   = xParams.Single(x => x.Name.ToLower() == "classname").Value,
                LibraryFile = xParams.Single(x => x.Name.ToLower() == "libraryfile").Value,
                MethodName  = xParams.Single(x => x.Name.ToLower() == "methodname").Value
            };

            var          classObject = ActivateObject(config);
            ActionResult result      = null;

            switch (moduleType)
            {
            case ModuleType.Class:
                result = ExecuteClass(action, classObject);
                break;

            case ModuleType.Method:
                result = ExecuteMethod(action, classObject, config);
                break;
            }
            return(result);
        }
Exemple #7
0
        protected static ProcessStartInfo CreateProcessStartInfo(
            ISpecialExecutionTaskTestAction testAction,
            IParameter pathParameter,
            out string processArguments,
            out string expandedPath)
        {
            IInputValue path               = pathParameter.GetAsInputValue();
            IInputValue directoryValue     = testAction.GetParameterAsInputValue(Directory, true);
            IParameter  argumentsParameter = testAction.GetParameter(Arguments, true);

            processArguments = string.Empty;
            if (string.IsNullOrEmpty(path.Value))
            {
                throw new ArgumentException("Mandatory parameter '{Path}' not set.");
            }
            string directory = GetDirectory(directoryValue);

            if (argumentsParameter != null)
            {
                processArguments = ParseArguments(argumentsParameter);
            }
            expandedPath = Environment.ExpandEnvironmentVariables(path.Value);
            ProcessStartInfo processStartInfo = new ProcessStartInfo(expandedPath, processArguments);

            if (!string.IsNullOrEmpty(directory))
            {
                processStartInfo.WorkingDirectory = directory;
            }
            return(processStartInfo);
        }
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            String paraTargetHost = testAction.GetParameterAsInputValue("Host", false).Value;

            if (string.IsNullOrEmpty(paraTargetHost))
            {
                throw new ArgumentException(string.Format("Es muss ein Ziel (Host) angegeben sein."));
            }

            string paraMessage = testAction.GetParameterAsInputValue("Message", false).Value;

            if (string.IsNullOrEmpty(paraMessage))
            {
                throw new ArgumentException(string.Format("Es muss eine Message angegeben sein."));
            }

            string paraApi = testAction.GetParameterAsInputValue("API", false).Value;

            if (string.IsNullOrEmpty(paraApi))
            {
                throw new ArgumentException(string.Format("Es muss eine API angegeben sein."));
            }


            Uri checkRequest = new Uri(string.Format("http://{0}/checkMessage/?api={1}", paraTargetHost, paraApi));

            GetResponse(checkRequest);

            return(new PassedActionResult("Check result for request " + checkRequest));
        }
        public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
        {
            IInputValue path = testAction.GetParameterAsInputValue("Path");
            //IParameter result = testAction.GetParameter("Result");
            IParameter buffers = testAction.GetParameter("Buffers", true);
            IEnumerable <IParameter> arguments = buffers.GetChildParameters("Buffer");
            string returnValue = ExtractString(path.Value);

            string[] words = returnValue.Split(',');
            if (words.Length == arguments.Count())
            {
                int    index      = 0;
                string resultText = "Buffers Created:";
                foreach (IParameter argument in arguments)
                {
                    IInputValue arg = argument.Value as IInputValue;
                    Buffers.Instance.SetBuffer(arg.Value, words[index], false);
                    resultText = resultText + Environment.NewLine
                                 + "Name: " + arg.Value + Environment.NewLine
                                 + "Value: " + words[index];
                    index = index + 1;
                }
                testAction.SetResultForParameter(buffers, SpecialExecutionTaskResultState.Ok, string.Format(resultText));
            }
            else
            {
                testAction.SetResultForParameter(buffers, SpecialExecutionTaskResultState.Failed, string.Format("File does not have all the buffers!"));
            }
        }
Exemple #10
0
        public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
        {
            IParameter expectedFilePathParameter = testAction.GetParameter("ExpectedFile", false, new[] { ActionMode.Input });
            IParameter actualFilePathParameter = testAction.GetParameter("ActualFile", false, new[] { ActionMode.Input });

            string expectedFilePath = Environment.ExpandEnvironmentVariables(expectedFilePathParameter.GetAsInputValue().Value);
            string actualFilePath = Environment.ExpandEnvironmentVariables(actualFilePathParameter.GetAsInputValue().Value);
            string result = String.Empty;
            try
            {
                result = FileComparer.Compare(expectedFilePath, actualFilePath);
            }
            catch (FileNotFoundException exc)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Failed, exc.Message);
                return;
            }

            if (result == String.Empty)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Ok, "The contents of the files are identical.");
            }
            else
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Failed, result);
            }
        }
Exemple #11
0
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            IInputValue setfailed  = testAction.GetParameterAsInputValue(c_SetFailed, false);
            IInputValue failuretyp = testAction.GetParameterAsInputValue(c_FailureTyp, false);
            IInputValue message    = testAction.GetParameterAsInputValue(c_Message, false);


            if (string.IsNullOrEmpty(setfailed.Value))
            {
                t_setfailed = "Failed";
            }
            else
            {
                t_setfailed = setfailed.Value;
            }

            if (!string.IsNullOrEmpty(failuretyp.Value))
            {
                t_failuretyp = failuretyp.Value;
            }

            if (!string.IsNullOrEmpty(message.Value))
            {
                t_message = message.Value;
            }

            string message_all = "Failuretyp: " + t_failuretyp + "; Message: " + t_message;

            if (t_setfailed == "Failed")
            {
                try
                {
                    if (t_failuretyp == "Warn" || t_failuretyp == "Absence" || t_failuretyp == "Missing")
                    {
                        return(new PassedActionResult("Test " + t_setfailed + " > " + message_all + " <"));
                    }

                    if (t_failuretyp == "Other Failure")
                    {
                        return(new PassedActionResult("Test " + t_setfailed + " > " + message_all + " <"));
                    }
                    else
                    {
                        throw (new TestFailedException("Test " + t_setfailed + " > " + message_all + " <"));
                    }
                }
                catch (TestFailedException e)
                {
                    throw (new TestFailedException("Test " + t_setfailed + " > " + message_all + " <\r\n", e));
                }
                finally
                {
                }

                // return new PassedActionResult("Test failed: " + message_all);
            }

            return(new PassedActionResult("Passed successfully: " + message_all));
        }
Exemple #12
0
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            IInputValue FilePath = testAction.GetParameterAsInputValue("FilePath", false); //isOptional=true

            Process.Start(FilePath.Value);

            return(new PassedActionResult("File Opened Successfully"));
        }
Exemple #13
0
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            bool        completed     = false;
            string      returnMsg     = "";
            IInputValue paramURL      = testAction.GetParameterAsInputValue(URL, false);
            IInputValue paramIsNewTab = testAction.GetParameterAsInputValue(isNewTab, false);

            if (paramURL == null || string.IsNullOrEmpty(paramURL.Value))
            {
                throw new ArgumentException(string.Format("Mandatory parameter '{0}' not set.", URL));
            }

            if (paramIsNewTab == null || string.IsNullOrEmpty(paramIsNewTab.Value))
            {
                throw new ArgumentException(string.Format("Mandatory parameter '{0}' not set.", isNewTab));
            }

            try
            {
                if (paramIsNewTab.Value == "True")
                {
                    ShellWindows shellWindows = new ShellWindows();  //Uses SHDocVw to get the Internet Explorer Instances
                    foreach (SHDocVw.InternetExplorer internetExplorerInstance in shellWindows)
                    {
                        string url = internetExplorerInstance.LocationURL;
                        if (!url.Contains("file:///"))
                        {
                            internetExplorerInstance.Navigate(paramURL.Value, 0x800);
                            completed = true;
                            returnMsg = "URL opened in new tab";
                            break;
                        }
                    }
                }

                if (!completed)   // To open url in new window
                {
                    Process procInNewWndow = new Process();
                    procInNewWndow.StartInfo.FileName        = "C:\\Program Files\\Internet Explorer\\iexplore.exe";
                    procInNewWndow.StartInfo.Arguments       = paramURL.Value;
                    procInNewWndow.StartInfo.UseShellExecute = true;
                    procInNewWndow.StartInfo.CreateNoWindow  = false;
                    procInNewWndow.Start();
                    returnMsg = "URL opened in new window";
                }
            }
            catch (Exception)
            {
                return(new UnknownFailedActionResult("Could not start program",
                                                     string.Format(
                                                         "Failed while trying to start:\nURL: {0}\r\nIsNewTab: {1}",
                                                         paramURL.Value, paramIsNewTab.Value),
                                                     ""));
            }

            return(new PassedActionResult(returnMsg));
        }
Exemple #14
0
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            String relay = testAction.GetParameterAsInputValue("relay", false).Value;

            if (string.IsNullOrEmpty(relay))
            {
                throw new ArgumentException(string.Format("Es muss ein SMTP Relay angegeben sein."));
            }

            String sendTo = testAction.GetParameterAsInputValue("to", false).Value;

            if (string.IsNullOrEmpty(sendTo))
            {
                throw new ArgumentException(string.Format("Es muss ein Empfänger angegeben werden."));
            }

            String sendFrom = testAction.GetParameterAsInputValue("from", false).Value;

            if (string.IsNullOrEmpty(sendFrom))
            {
                throw new ArgumentException(string.Format("Es muss ein Absender angegeben werden."));
            }

            String msgSubject = testAction.GetParameterAsInputValue("subject", false).Value;

            if (string.IsNullOrEmpty(msgSubject))
            {
                throw new ArgumentException(string.Format("Es muss ein Betreff angegeben sein."));
            }

            String msgBody = testAction.GetParameterAsInputValue("body", false).Value;

            if (string.IsNullOrEmpty(msgBody))
            {
                throw new ArgumentException(string.Format("Es muss ein Text (Body) angegeben sein."));
            }

            MailMessage message = new MailMessage(sendFrom, sendTo);

            message.Subject = msgSubject;
            message.Body    = @msgBody;

            using (SmtpClient client = new SmtpClient(relay)) {
                // client.UseDefaultCredentials = true;

                try {
                    client.Send(message);
                    return(new PassedActionResult("Message successfully sent."));
                }
                catch (Exception ex) {
                    return(new NotFoundFailedActionResult("Exception caught in CreateTestMessage2(): {0}",
                                                          ex.ToString()));
                } finally {
                }
            }
        }
Exemple #15
0
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            String paraBuffer = testAction.GetParameterAsInputValue("Value", false).Value;

            if (string.IsNullOrEmpty(paraBuffer))
            {
                throw new ArgumentException(string.Format("Es muss ein Buffer angegeben sein."));
            }

            return(new PassedActionResult(paraBuffer));
        }
Exemple #16
0
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            IInputValue showinfo = testAction.GetParameterAsInputValue(c_ShowInfo, false);

            /*
             * if (showinfo == null || string.IsNullOrEmpty(showinfo.Value))
             *  throw new ArgumentException(string.Format("Mandatory parameter '{0}' not set.", c_ShowInfo));
             */

            return(new PassedActionResult("Info: " + showinfo.Value));
        }
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            String inputStr = testAction.GetParameterAsInputValue("InputString", false).Value;

            if (string.IsNullOrEmpty(inputStr))
            {
                throw new ArgumentException(string.Format("Please provide input string to be converted to uppercase!"));
            }

            string resultString = inputStr.ToUpper();

            return(new PassedActionResult(resultString));
        }
Exemple #18
0
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            IInputValue name = testAction.GetParameterAsInputValue(Name, false);
            string      browserProcessName = string.Empty;
            string      result             = string.Empty;

            try
            {
                // Setting Browser process Name as per browserName
                switch (name.Value)
                {
                case "Internet Explorer":
                    browserProcessName = "iexplore";
                    break;

                case "Google Chrome":
                    browserProcessName = "chrome";
                    break;

                case "Mozilla Firefox":
                    browserProcessName = "firefox";
                    break;

                default:
                    return(new UnknownFailedActionResult("Could not kill program", string.Format("Failed while trying to kill {0}", name.Value), ""));
                }
                Process[] procs = Process.GetProcessesByName(browserProcessName);
                if (procs.Length > 0)
                {
                    foreach (Process proc in procs)
                    {
                        proc.Kill();
                        result = name.Value + " Browser closed Successfully";
                    }
                }
                else
                {
                    result = name.Value + ERROR_BROWSER_NOTAVAILABLE;
                }
            }
            catch (Exception)
            {
                return(new UnknownFailedActionResult("Could not kill program",
                                                     string.Format(
                                                         "Failed while trying to kill {0}",
                                                         name.Value),
                                                     ""));
            }

            return(new PassedActionResult(result));
        }
Exemple #19
0
        public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
        {
            IParameter IPconnString = testAction.GetParameter("ConnectionString", false, new[] { ActionMode.Input });
            IParameter IPquery      = testAction.GetParameter("Query", false, new[] { ActionMode.Input });
            IParameter IPresult     = testAction.GetParameter("Result", true, new[] { ActionMode.Verify, ActionMode.Buffer });

            string connString = IPconnString.GetAsInputValue().Value;
            string query      = IPquery.GetAsInputValue().Value;


            if (File.Exists(query))
            {
                query = File.ReadAllText(query);
            }

            Datalink dl = new Datalink(connString);

            if (!dl.IsValidSqlConnectionString())
            {
                throw new InvalidOperationException("Connectionstring is not valid or the database cannot be reached");
            }

            string result = dl.Execute(query);

            if (IPresult != null)
            {
                IInputValue expectedResult = IPresult.Value as IInputValue;

                if (IPresult.ActionMode == ActionMode.Buffer)
                {
                    Buffers.Instance.SetBuffer(expectedResult.Value, result);
                    testAction.SetResult(SpecialExecutionTaskResultState.Ok, string.Format("Buffer {0} set to value {1}.", expectedResult.Value, result));
                    return;
                }

                if (expectedResult.Value == result)
                {
                    testAction.SetResult(SpecialExecutionTaskResultState.Ok, "Actual rows match expected number of rows.");
                }
                else
                {
                    testAction.SetResult(SpecialExecutionTaskResultState.Failed, string.Format("Expected result: {0}. Actual result {1}. Incorrect", expectedResult.Value, result.ToString()));
                }
            }
            else
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Ok, "Query executed");
            }
        }
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            String paraTargetHost = testAction.GetParameterAsInputValue("Host", false).Value;

            if (string.IsNullOrEmpty(paraTargetHost))
            {
                throw new ArgumentException(string.Format("Es muss ein Ziel (Host) angegeben sein."));
            }

            Uri resetRequest = new Uri("http://" + paraTargetHost + "/resetSession");

            GetResponse(resetRequest);

            return(new PassedActionResult("Session reset on: " + paraTargetHost));
        }
Exemple #21
0
        public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
        {
            //The 2nd parameter of GetParameterAsInputValue Method defines if the argument is optional or not
            //and if we don't provide the second parameter by default it is false(Means argument is mandetory)
            IInputValue browserName = testAction.GetParameterAsInputValue("BrowserName", false);
            bool        result      = EraseTemporaryFiles(browserName.Value);

            if (result)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Ok, string.Format("Cache for {0} is cleared.", browserName.Value));
            }
            else
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Failed, string.Format("Unable to clear cache for {0}.", browserName.Value));
            }
        }
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            String base64ImageRepresentation = testAction.GetParameterAsInputValue("Payload", false).Value;
            String targetFile = testAction.GetParameterAsInputValue("TargetFile", false).Value;

            if (targetFile != null && base64ImageRepresentation != null)
            {
                System.IO.File.WriteAllBytes(targetFile, Convert.FromBase64String(base64ImageRepresentation));
            }
            else
            {
                throw new ArgumentException();
            }

            return(new PassedActionResult("Decoding File successfully completed"));
        }
Exemple #23
0
        public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
        {
            IParameter IPconnString = testAction.GetParameter("ConnectionString", false, new[] { ActionMode.Input });
            IParameter IPquery = testAction.GetParameter("Query", false, new[] { ActionMode.Input });
            IParameter IPresult = testAction.GetParameter("Result", true, new[] { ActionMode.Verify, ActionMode.Buffer });

            string connString = IPconnString.GetAsInputValue().Value;
            string query = IPquery.GetAsInputValue().Value;

            if (File.Exists(query))
            {
                query = File.ReadAllText(query);
            }

            Datalink dl = new Datalink(connString);

            if (!dl.IsValidSqlConnectionString())
            {
                throw new InvalidOperationException("Connectionstring is not valid or the database cannot be reached");
            }

            string result = dl.Execute(query);
            if (IPresult != null )
            {
                IInputValue expectedResult = IPresult.Value as IInputValue;

                if (IPresult.ActionMode == ActionMode.Buffer)
                {
                    Buffers.Instance.SetBuffer(expectedResult.Value, result);
                    testAction.SetResult(SpecialExecutionTaskResultState.Ok, string.Format("Buffer {0} set to value {1}.",expectedResult.Value, result));
                    return;
                }

                if (expectedResult.Value == result)
                {
                    testAction.SetResult(SpecialExecutionTaskResultState.Ok, "Actual rows match expected number of rows.");
                }
                else
                {
                    testAction.SetResult(SpecialExecutionTaskResultState.Failed, string.Format("Expected result: {0}. Actual result {1}. Incorrect", expectedResult.Value, result.ToString()));
                }
            }
            else
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Ok, "Query executed");
            }
        }
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            String sourceFile          = testAction.GetParameterAsInputValue("InputFile", false).Value;
            String bufferParameterName = testAction.GetParameterAsInputValue("BufferParamName", false).Value;

            if (sourceFile != null && bufferParameterName != null)
            {
                string base64ImageRepresentation = Convert.ToBase64String(System.IO.File.ReadAllBytes(sourceFile));
                Buffers.Instance.SetBuffer(bufferParameterName, base64ImageRepresentation, false);
            }
            else
            {
                throw new ArgumentException();
            }

            return(new PassedActionResult("Encoding File successfully completed"));
        }
		public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
		{
			String paraExchangeFile = testAction.GetParameterAsInputValue("File", false).Value;
			if (string.IsNullOrEmpty(paraExchangeFile)) {
				throw new ArgumentException(string.Format("Es muss eine Exchangedatei (File) angegeben sein."));
			}
			
			if (!Collections.Instance.CollectionExists(BufferCollectionPath)) {
				throw new InvalidOperationException("Es existiert keine Buffer-Collection in den Einstellungen!");
			}
			
			XmlDocument doc = new XmlDocument();

			XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
			XmlElement root = doc.DocumentElement;
			doc.InsertBefore(xmlDeclaration, root);

			XmlElement bodyElement = doc.CreateElement(string.Empty, "exchange", string.Empty);
			doc.AppendChild(bodyElement);

			XmlElement varElement = doc.CreateElement(string.Empty, "variables", string.Empty);
			bodyElement.AppendChild(varElement);

			foreach (
				
				KeyValuePair<string, string> buffer in Collections.Instance.GetCollectionEntries(BufferCollectionPath)) {
				if (!string.IsNullOrEmpty(buffer.Value) && !buffer.Key.StartsWith("#")) {
					XmlElement varKey = doc.CreateElement(string.Empty, buffer.Key, string.Empty);
					XmlText varValue;
					if (buffer.Key == "QAPass") {
						varValue = doc.CreateTextNode("****");
						varKey.AppendChild(varValue);
					} else {
						varValue = doc.CreateTextNode(buffer.Value);
						varKey.AppendChild(varValue);
					}
					varElement.AppendChild(varKey);
				}
			}

			doc.Save(paraExchangeFile);
			
			return new PassedActionResult("Exchange generated to: " + paraExchangeFile);
		}
Exemple #26
0
        public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
        {
            IParameter IPprocess      = testAction.GetParameter("Process", false, new[] { ActionMode.Input });
            IParameter IPwaittimesecs = testAction.GetParameter("WaitTimeSecs", false, new[] { ActionMode.Input });

            string process            = IPprocess.GetAsInputValue().Value;
            string waittimesecsString = IPwaittimesecs.GetAsInputValue().Value;

            short waittimesecs = 0;
            bool  success      = Int16.TryParse(waittimesecsString, out waittimesecs);

            if (!success)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Failed, "WaitTimeSecs has to be an integer");
                return;
            }

            if (waittimesecs == 0)
            {
                waittimesecs = DEFAULTWAITTIME;
            }

            Process[] pname = Process.GetProcessesByName(process);
            if (pname.Length == 0)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Ok, string.Format("Proces {0} already ended or not started", process));
                return;
            }

            short counter = 0;

            while (counter < waittimesecs)
            {
                counter++;
                Thread.Sleep(1000);
                pname = Process.GetProcessesByName(process);
                if (pname.Length == 0)
                {
                    break;
                }
            }

            testAction.SetResult(SpecialExecutionTaskResultState.Ok, string.Format("Proces {0} has ended after {1} seconds", process, counter));
        }
Exemple #27
0
 public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
 {
     foreach (IParameter parameter in testAction.Parameters)
     {
         //ActionMode input means set the buffer
         if (parameter.ActionMode == ActionMode.Input)
         {
             IInputValue inputValue = parameter.GetAsInputValue();
             //Buffers.Instance.SetBuffer(parameter.Name, inputValue.Value);
             testAction.SetResultForParameter(parameter, SpecialExecutionTaskResultState.Ok, string.Format("Buffer {0} set to value {1}.", parameter.Name, inputValue.Value));
         }
         //Otherwise we let TBox handle the verification. Other ActionModes like WaitOn will lead to an exception.
         else
         {
             //Don't need the return value of HandleActualValue in this case.
             //HandleActualValue(testAction, parameter, Buffers.Instance.GetBuffer(parameter.Name));
         }
     }
 }
 public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
 {
     if (!Collections.Instance.CollectionExists(BufferCollectionPath))
     {
         throw new InvalidOperationException("No Buffer-Collection is available in the settings!");
     }
     foreach (
         KeyValuePair <string, string> buffer in Collections.Instance.GetCollectionEntries(BufferCollectionPath))
     {
         if (!string.IsNullOrEmpty(buffer.Value))
         {
             if ((!buffer.Key.StartsWith("LOCAL_")) && (!buffer.Key.StartsWith("ENV")) && (!buffer.Key.StartsWith("TOOLS_")))
             {
                 Buffers.Instance.SetBuffer(buffer.Key, string.Empty, false);
             }
         }
     }
     testAction.SetResult(SpecialExecutionTaskResultState.Ok, "Successfully cleared all Buffers!");
 }
Exemple #29
0
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            String filePath  = testAction.GetParameterAsInputValue("FilePath", false).Value;
            String rowNumber = testAction.GetParameterAsInputValue("RowNumber", false).Value;

            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentException(string.Format("Text file path is required."));
            }

            if (string.IsNullOrEmpty(rowNumber))
            {
                throw new ArgumentException(string.Format("Row number with column names is required."));
            }

            int i   = 0;
            int row = Int32.Parse(rowNumber);

            int[] columnSize = { 14, 3, 4, 7, 7, 3, 3, 3, 10, 3, 6, 2, 5, 8, 6, 10, 13, 9, 8, 3, 16, 25, 8 };

            string resultString = "Column Names: ";

            string[] lines = File.ReadAllLines(filePath);

            foreach (string line in lines)
            {
                if (line.Equals(lines[row - 1]) && i == 0)
                {
                    string columnNames  = line.Substring(1);
                    int    columnLength = 0;

                    for (int x = 0; x < columnSize.Length; x++)
                    {
                        columnLength  = columnSize[x];
                        resultString += columnNames.Substring(i, columnLength + 1).Trim() + ", ";
                        i             = i + columnLength + 1;
                    }
                }
            }

            return(new PassedActionResult(resultString));
        }
Exemple #30
0
        public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
        {
            //  IParameter Parentparam =  testAction.GetParameter("BufferCredentials",false);

            //   IEnumerable<IParameter> Childparam = Parentparam.GetChildParameters("BufferCredentials");

            foreach (IParameter Param in testAction.Parameters)
            {
                if (Param.ActionMode == ActionMode.Input)
                {
                    IInputValue inputValue = Param.GetAsInputValue();
                    Buffers.Instance.SetBuffer(Param.Name, Param.GetAsInputValue().Value, false);
                    testAction.SetResultForParameter(Param, SpecialExecutionTaskResultState.Ok, string.Format("Buffer {0} set for value {1}", Param.Name, inputValue.Value));
                }
                else
                {
                    testAction.SetResultForParameter(Param, SpecialExecutionTaskResultState.Failed, string.Format("Fail"));
                }
            }
        }
Exemple #31
0
 public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
 {
     //Iterate over each TestStepValue
     foreach (IParameter parameter in testAction.Parameters)
     {
         //ActionMode input means set the buffer
         if (parameter.ActionMode == ActionMode.Input)
         {
             IInputValue inputValue = parameter.GetAsInputValue();
             Buffers.Instance.SetBuffer(parameter.Name, inputValue.Value, false);
             testAction.SetResultForParameter(parameter, SpecialExecutionTaskResultState.Ok, string.Format("Buffer {0} set to value {1}.", parameter.Name, inputValue.Value));
         }
         //Otherwise we let TBox handle the verification. Other ActionModes like WaitOn will lead to an exception.
         else
         {
             //Don't need the return value of HandleActualValue in this case.
             HandleActualValue(testAction, parameter, Buffers.Instance.GetBuffer(parameter.Name));
         }
     }
 }
Exemple #32
0
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            try
            {
                IInputValue buffer   = testAction.GetParameterAsInputValue("Buffer Name", false, new[] { ActionMode.Input });
                IInputValue folder   = testAction.GetParameterAsInputValue("Folder Path", false, new[] { ActionMode.Input });
                IInputValue fileName = testAction.GetParameterAsInputValue("File Name", false, new[] { ActionMode.Input });

                string fileContent = Buffers.Instance.GetBuffer(buffer.Value);
                if (fileContent.StartsWith("\"") && fileContent.EndsWith("\""))
                {
                    fileContent = fileContent.TrimStart('"').TrimEnd('"').Replace("\"\"", "\"");
                }
                File.WriteAllText(Path.Combine(folder.Value, fileName.Value), fileContent);
                return(new PassedActionResult("File created as '" + Path.Combine(folder.Value, fileName.Value) + "'."));
            }
            catch (Exception e)
            {
                return(new UnknownFailedActionResult(e.Message));
            }
        }
Exemple #33
0
        public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
        {
            IParameter       pathParameter = testAction.GetParameter(Path);
            string           processArguments = null, expandedPath = null;
            ProcessStartInfo processStartInfo = null;

            try {
                processStartInfo = CreateProcessStartInfo(
                    testAction,
                    pathParameter,
                    out processArguments,
                    out expandedPath);
            }
            catch (FileNotFoundException e) {
                testAction.SetResultForParameter(pathParameter, new UnknownFailedActionResult("Cannot find the given file'.", e.ToString(), expandedPath ?? string.Empty));
                return;
            }
            IParameter exitParameter = testAction.GetParameter(WaitForExit, true, new[] { ActionMode.Select });

            if (exitParameter != null)
            {
                StartProgramWithWaitForExit(
                    testAction,
                    exitParameter,
                    processStartInfo,
                    pathParameter,
                    expandedPath,
                    processArguments);
            }
            else
            {
                StartProgramWithoutWaitingForExit(
                    testAction,
                    processStartInfo,
                    expandedPath,
                    processArguments,
                    pathParameter);
            }
        }
Exemple #34
0
 private static void StartProgramWithoutWaitingForExit(
     ISpecialExecutionTaskTestAction testAction,
     ProcessStartInfo processStartInfo,
     string expandedPath,
     string processArguments,
     IParameter pathParameter)
 {
     try {
         Process.Start(processStartInfo);
         testAction.SetResult(
             SpecialExecutionTaskResultState.Ok,
             "Started: " + expandedPath + " with arguments: " + processArguments);
     }
     catch (Win32Exception e) {
         testAction.SetResultForParameter(
             pathParameter,
             SpecialExecutionTaskResultState.Failed,
             CreateMessageForStartError(expandedPath, processArguments, e),
             e.StackTrace,
             "");
     }
 }
Exemple #35
0
        public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
        {
            IParameter IPprocess = testAction.GetParameter("Process", false, new[] { ActionMode.Input });
            IParameter IPwaittimesecs = testAction.GetParameter("WaitTimeSecs", false, new[] { ActionMode.Input });

            string process = IPprocess.GetAsInputValue().Value;
            string waittimesecsString = IPwaittimesecs.GetAsInputValue().Value;

            short waittimesecs = 0;
            bool success = Int16.TryParse(waittimesecsString, out waittimesecs);
            if (!success)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Failed, "WaitTimeSecs has to be an integer");
                return;
            }

            if (waittimesecs == 0)
                waittimesecs = DEFAULTWAITTIME;

            Process[] pname = Process.GetProcessesByName(process);
            if (pname.Length == 0)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Ok, string.Format("Proces {0} already ended or not started", process));
                return;
            }

            short counter = 0;
            while (counter < waittimesecs)
            {
                counter++;
                Thread.Sleep(1000);
                pname = Process.GetProcessesByName(process);
                if (pname.Length == 0)
                    break;
            }

            testAction.SetResult(SpecialExecutionTaskResultState.Ok, string.Format("Proces {0} has ended after {1} seconds", process, counter));
        }
Exemple #36
0
        public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
        {
            const string BEGINWHERE = " where 1=1 ";
            const string BEGINSELECT = " select ";
            const string BEGINORDER = " order by ";
            const string ORDERDIRECTION = " desc ";

            var connStringParam = testAction.SearchQuery.XParameters.ConfigurationParameters.FirstOrDefault( xParam => xParam.Name == "ConnectionString");
            string connString = connStringParam.UnparsedValue;

            var tableNameParam = testAction.SearchQuery.XParameters.ConfigurationParameters.FirstOrDefault(xParam => xParam.Name == "TableName");
            string tableName = tableNameParam.UnparsedValue;

            var orderAttribParam = testAction.SearchQuery.XParameters.ConfigurationParameters.FirstOrDefault(xParam => xParam.Name == "OrderAttribute");
            string orderAttrib = orderAttribParam.UnparsedValue;

            string queryWhere = BEGINWHERE;
            string queryBegin = BEGINSELECT;
            string query = string.Empty;
            string queryOrder = string.Format("{0} {1} {2}", BEGINORDER, orderAttrib, ORDERDIRECTION);
            int count = 0;

            var constraints = testAction.Parameters.FindAll(p => p.ActionMode == ActionMode.Constraint);
            if (constraints.Count > 0)
            {
                foreach (var parameter in constraints)
                {
                    IInputValue value = parameter.Value as IInputValue;
                    queryWhere += string.Format(" and {0} = '{1}' ", parameter.Name, value.Value);
                }
            }

            var buffersVerifies = testAction.Parameters.FindAll(p => p.ActionMode == ActionMode.Verify || p.ActionMode == ActionMode.Buffer);

            if (buffersVerifies.Count == 0 )
            {
                // No use in continuing if there is nothing to verify or buffer
                return;
            }

            queryBegin += String.Join(",", buffersVerifies.Select(p => p.Name).ToArray());

            // Generate db query
            query = string.Format("{0} FROM {1} {2} {3}", queryBegin, tableName, queryWhere, queryOrder);

            // Connect to the database
            Datalink dl = new Datalink();
            dl.ConnectionString = connString;
            if (!dl.IsValidSqlConnectionString())
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Failed, string.Format("Cannot connect to the SQL database with the following connection string: {0}", connString));
                return;
            }

            DataRow dr = dl.GetRowFromDb(query);
            // If there is not a result from the database, set the testresult to failed
            if (dr == null)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Failed, "No records found in with selected searchcriteria" );
                return;
            }

            foreach (IParameter parameter in buffersVerifies.Where(p => p.ActionMode == ActionMode.Verify))
            {
                IInputValue value = parameter.Value as IInputValue;
                if (value.Value == dr[parameter.Name].ToString())
                {
                    testAction.SetResultForParameter(parameter, SpecialExecutionTaskResultState.Ok, string.Format("{0}: Expected value {1} matches actual value {2}.", parameter.Name, value.Value, dr[parameter.Name].ToString()));
                }
                else
                {
                    count++;
                    testAction.SetResultForParameter(parameter, SpecialExecutionTaskResultState.Failed, string.Format("Error {0}: Expected value {1} does not match actual value {2}.", parameter.Name, value.Value, dr[parameter.Name].ToString()));
                }
            }

            foreach (IParameter parameter in buffersVerifies.Where(p => p.ActionMode == ActionMode.Buffer))
            {
                IInputValue buffer = parameter.Value as IInputValue;
                Buffers.Instance.SetBuffer(buffer.Value, dr[parameter.Name].ToString());
                testAction.SetResultForParameter(parameter, SpecialExecutionTaskResultState.Ok, string.Format("Buffer {0} set to value {1}.", buffer.Value, dr[parameter.Name].ToString()));
            }

            if (count == 0)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Ok, "All values match.");
            }
            else
            {
                int numberOfVerifies = buffersVerifies.Count(p => p.ActionMode == ActionMode.Verify);
                testAction.SetResult(SpecialExecutionTaskResultState.Failed, string.Format("{0} out of {1} values match.", numberOfVerifies - count, numberOfVerifies));
            }
        }