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!"));
            }
        }
Esempio n. 2
0
        public static void Execute()
        {
            foreach (string tmpName in dicInject.Keys)
            {
                IInjector owner = dicInject[tmpName];

                List <ITemplate> tmpList = dicTemplates[tmpName];
                IInputValue      inputVO = dicInput[tmpName];
                IInitValue       initVO  = dicInit[tmpName];

                FileSettingText setting = dicSetting[tmpName];


                owner.Init(initVO);
                owner.Inject(inputVO, tmpList);


                foreach (ITemplate iTemp in tmpList)
                {
                    string FileName = iTemp.GetType().ToString();

                    string writeContent = iTemp.TransformText();

                    string directoryPath = setting.SaveTo;
                    string filePath      = directoryPath + FileName;

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

                    File.WriteAllText(filePath, writeContent);
                }
            }
        }
Esempio n. 3
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);
        }
Esempio n. 4
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));
        }
Esempio n. 5
0
        static void reflect(IEnumerable <FileSettingText> configs)
        {
            Assembly[] AssembliesLoaded = AppDomain.CurrentDomain.GetAssemblies();


            foreach (FileSettingText config in configs)
            {
                foreach (InjectSettingText injSetting in config.InjectSettings)
                {
                    string path       = injSetting.Assembly;
                    var    assemblies = new Assembly[] { Assembly.LoadFile(path) };


                    IInjector injectObj = Global.getTypedObject <IInjector>(assemblies, injSetting.Injector);

                    if (injectObj == null)
                    {
                        Global.LogError("");
                        continue;
                    }



                    IEnumerable <string> aaa          = injSetting.Templates.Trim('[', ']').Split(',').Select(obj => obj.Trim());
                    List <ITemplate>     templateList = new List <ITemplate>();


                    foreach (string templates in aaa)
                    {
                        ITemplate template = Global.getTypedObject <ITemplate>(assemblies, templates);

                        if (template == null)
                        {
                            Global.LogError("");
                            continue;
                        }

                        templateList.Add(template);
                    }


                    IInitValue  initValue  = injectObj.GetInitValue();
                    IInputValue inputValue = injectObj.GetInputValue();

                    initValue.SetValue(injSetting.InitValue);
                    inputValue.SetValue(injSetting.InputValue);



                    Global.dicTemplates.Add(config.Name, templateList);
                    Global.dicInput.Add(config.Name, inputValue);
                    Global.dicInit.Add(config.Name, initValue);
                    Global.dicInject.Add(config.Name, injectObj);
                }


                Global.dicSetting.Add(config.Name, config);
            }
        }
Esempio n. 6
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"));
        }
Esempio n. 7
0
        public void SetObject(Type type)
        {
            if (type == null)
            {
                Debug.LogError("type parameter is null!");
                return;
            }
            this.cached_type = type;

            Type[] type_args = type.GetGenericArguments();

            serialized_type = serialized_type ?? (serialized_type = new SerializedType(type, type_args));

            this.name  = type.GetTypeName(true);
            this.title = type.GetTypeName();

            if (!type.IsStatic())
            {
                this.target = (IInputValue)RegisterInputValue(type, "Target");
            }

            BindingFlags flags = BindingFlags.Public | BindingFlags.Instance | (use_inherit ? BindingFlags.Default : BindingFlags.DeclaredOnly) | (use_private ? BindingFlags.NonPublic : BindingFlags.Default) | (use_static ? BindingFlags.Static : BindingFlags.Default);
            int          index = 0;

            foreach (MethodInfo method_info in type.GetMethods(flags))
            {
                if (method_info.IsGenericMethod && method_info.IsGenericMethodDefinition)
                {
                    continue;
                }
                string key         = method_info.GetSignName();
                string method_name = method_info.Name;
                Type[] method_args = method_info.GetGenericArguments();

                SerializedMethod sm;
                if (!this.serialized_methods.TryGetValue(key, out sm))
                {
                    this.serialized_methods[key] = new SerializedMethod(method_info, method_args);
                }

                if (method_info.ReturnType == typeof(void))
                {
                    RegisterEntryPort(string.Format("{0}. {1}", index, method_name), () => { Execute(key); });
                    this.act_outputs[key] = RegisterExitPort(string.Format("{0}. Out", index));
                }
                else
                {
                    RegisterOutputValue(method_info.ReturnType, string.Format("{0}. {1}", index, method_name), () => { return(Invoke(key)); });
                }

                parameters[key] = new List <IInputValue>();
                foreach (ParameterInfo parameter in method_info.GetParameters())
                {
                    parameters[key].Add((IInputValue)RegisterInputValue(parameter.ParameterType, string.Format("{0}. {1}", index, parameter.Name.AddSpacesToSentence())));
                }
                index++;
            }
        }
Esempio n. 8
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));
        }
Esempio n. 9
0
 public void Inject(IInputValue data, IEnumerable <ITemplate> templates)
 {
     foreach (ITemplate tmp in templates)
     {
         if (tmp is SampleTemplateProject.Template.SampleTemplate1)
         {
         }
     }
 }
Esempio n. 10
0
        private static string GetDirectory(IInputValue directoryValue)
        {
            string directory = null;

            if (directoryValue != null)
            {
                directory = Environment.ExpandEnvironmentVariables(directoryValue.Value);
            }
            return(directory);
        }
Esempio n. 11
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));
        }
Esempio n. 12
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));
        }
Esempio n. 13
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");
            }
        }
Esempio n. 14
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));
            }
        }
Esempio n. 15
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"));
                }
            }
        }
Esempio n. 16
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));
         }
     }
 }
Esempio n. 17
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));
            }
        }
Esempio n. 18
0
        private static string ParseArguments(IParameter argumentsParameter)
        {
            bool autoAddDoubleQuotes                = GetAutoAddDoubleQuotes(argumentsParameter);
            IEnumerable <IParameter> arguments      = argumentsParameter.GetChildParameters(Argument);
            const string             Doublequotes   = "\"";
            List <String>            argumentValues = new List <string>();

            foreach (IParameter argument in arguments)
            {
                IInputValue processArgument = argument.GetAsInputValue();
                string      value           = processArgument.Value;
                value = Environment.ExpandEnvironmentVariables(value);
                if (autoAddDoubleQuotes && value.Contains(" ") &&
                    !(value.StartsWith(Doublequotes) && value.EndsWith(Doublequotes)))
                {
                    value = Doublequotes + value + Doublequotes;
                }
                argumentValues.Add(value);
            }
            return(String.Join(" ", argumentValues.ToArray()));
        }
Esempio n. 19
0
        /*Generate the HMAC Signature in accordance to Pre-Request Script provided by First Data*/
        private string GetHmacSignature(IInputValue key, IInputValue secret, IInputValue method, IInputValue payload, string time)
        {
            string rawSignature = key.Value + ':' + time;
            string requestBody  = payload.Value;
            var    encoding     = new System.Text.ASCIIEncoding();
            var    sha          = new SHA256Managed();

            if (method.Value.ToUpper() != "GET" && method.Value.ToUpper() != "DELETE")
            {
                string b64Body = Convert.ToBase64String(sha.ComputeHash(new System.Text.ASCIIEncoding().GetBytes(requestBody)));
                rawSignature = rawSignature + ":" + b64Body;
            }

            byte[] keyByte          = encoding.GetBytes(secret.Value);
            byte[] rawSignatureByte = encoding.GetBytes(rawSignature);

            using (var hmacsha256 = new HMACSHA256(keyByte))
            {
                byte[] hashmessage = hmacsha256.ComputeHash(rawSignatureByte);
                return(Convert.ToBase64String(hashmessage));
            }
        }
Esempio n. 20
0
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            IInputValue path             = testAction.GetParameterAsInputValue(Path, false);
            IParameter  parameter        = testAction.GetParameter(Arguments, true);
            string      processArguments = string.Empty;

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

            if (parameter != null)
            {
                IEnumerable <IParameter> arguments = parameter.GetChildParameters(Argument);
                //Get Input value of each argument
                foreach (IParameter argument in arguments)
                {
                    IInputValue processArgument = argument.Value as IInputValue;
                    processArguments += processArgument.Value + " ";
                }
            }

            try
            {
                Process.Start(path.Value, processArguments);
            }
            catch (Win32Exception)
            {
                return(new UnknownFailedActionResult("Could not start program",
                                                     string.Format(
                                                         "Failed while trying to start:\nPath: {0}\r\nArguments: {1}",
                                                         path.Value, processArguments),
                                                     ""));
            }

            return(new PassedActionResult("Started successfully"));
        }
Esempio n. 21
0
 Axon(string Id, IInputValue input, Neuron output)
     : this(Id)
 {
     InputNeuron = input;
     OutputNeuron = output;
 }
Esempio n. 22
0
 public Axon(string Id, Random rand, IInputValue input, Neuron output)
     : this(Id, input, output)
 {
     Weight = rand.NextDouble() * 2 - 1;     // [-1, 1]
 }
Esempio n. 23
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));
            }
        }
Esempio n. 24
0
 public CompareExtension(IInputValue operand, Comparison comparison, IInputValue value)
 {
     Operand = operand;
     Value = value;
     Comparison = comparison;
 }
Esempio n. 25
0
        public override ActionResult Execute(ISpecialExecutionTaskTestAction testAction)
        {
            String time = String.Empty;
            string hmacSignatureString = String.Empty;

            //TestStep Parameters
            IInputValue key           = testAction.GetParameterAsInputValue(Key, false);
            IInputValue secret        = testAction.GetParameterAsInputValue(Secret, false);
            IInputValue method        = testAction.GetParameterAsInputValue(Method, false);
            IInputValue payload       = testAction.GetParameterAsInputValue(Payload, false);
            IInputValue timeStamp     = testAction.GetParameterAsInputValue(TimeStamp, true);
            IParameter  hmacSignature = testAction.GetParameter("HMAC Signature",
                                                                false,
                                                                new[] { ActionMode.Buffer, ActionMode.Verify });

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

            //Use timestamp from TestStep parameter otherwise generate one autmatically
            time = (timeStamp == null) ? GetTime().ToString() : timeStamp.Value.ToString();

            //Get HMAC Signature from the provided parameters
            hmacSignatureString = GetHmacSignature(key, secret, method, payload, time);

            if (string.IsNullOrEmpty(hmacSignatureString))
            {
                testAction.SetResultForParameter(hmacSignature,
                                                 SpecialExecutionTaskResultState.Failed,
                                                 "The HMAC Signature was empty or null.");
                return(new UnknownFailedActionResult("Could not create HMAC Signature",
                                                     string.Format("Failed while trying to start:\nKey:\r\n {0}\r\nSecret: {1}\r\nMethod: {2}\r\nPayload: {3}\r\nTimeStamp: {4}",
                                                                   key.Value,
                                                                   secret.Value,
                                                                   method.Value,
                                                                   payload.Value,
                                                                   time),
                                                     ""));
            }
            else
            {
                HandleActualValue(testAction, hmacSignature, hmacSignatureString);
                return(new PassedActionResult(String.Format("HMAC: {0}\r\n\r\nValues:\r\nKey: {1}\r\nSecret: {2}\r\nMethod: {3}\r\nPayload:\r\n{4}\r\nTimeStamp: {5} ",
                                                            hmacSignatureString,
                                                            key.Value,
                                                            secret.Value,
                                                            method.Value,
                                                            payload.Value,
                                                            time)));
            }
        }
Esempio n. 26
0
        private void InputGUI()
        {
            Vector2 delta = current.delta;

            switch (current.type)
            {
            case EventType.MouseDown:
                GraphEditor.mouse_down_position = GraphEditor.mouse_position;
                switch (current.button)
                {
                case 0:
                    if (current.alt)
                    {
                        break;
                    }
                    if (GraphEditor.hover_node)
                    {
                        if (current.clickCount >= 2)
                        {
                            if (GraphEditor.hover_node is MacroNode)
                            {
                                SetGraphAsset(((MacroNode)GraphEditor.hover_node).reference);
                                current.Use();
                                return;
                            }
                            else
                            {
                                EditorUtils.OpenScriptByType(GraphEditor.hover_node.type);
                                current.Use();
                            }
                        }
                        if (GraphEditor.hover_port)
                        {
                            if (current.control)
                            {
                                if (GraphEditor.hover_port is OutputAction)
                                {
                                    UndoManager.RecordObject(GraphEditor.asset, string.Format("{0} Add Branch", GraphEditor.asset.name));
                                    set_dirty = true;
                                    QuickPlugPort(GraphEditor.hover_port, AddNode <Branch>(GraphEditor.mouse_position / GraphEditor.zoom - GraphEditor.scroll + new Vector2(60.0f, 0.0f)));
                                }
                            }
                            else
                            {
                                if (current.shift)
                                {
                                    GraphEditor.can_drag_node = false;
                                    GraphEditor.can_drag_port = false;
                                    if (GraphEditor.hover_port is IPlug)
                                    {
                                        UndoManager.RecordObject(GraphEditor.asset, string.Format("{0} > {1}: {2} Unplug", GraphEditor.asset.name, GraphEditor.hover_node.name, GraphEditor.hover_port.name));
                                        set_dirty = true;
                                        ((IPlug)GraphEditor.hover_port).Unplug();
                                    }
                                    current.Use();
                                }
                                else
                                {
                                    GraphEditor.can_drag_node = false;
                                    GraphEditor.can_drag_port = true;
                                    SelectOnlyNode(GraphEditor.hover_node);
                                    current.Use();
                                }
                            }
                        }
                        else
                        {
                            if (current.shift)
                            {
                                if (GraphEditor.hover_node.is_selected)
                                {
                                    GraphEditor.can_drag_node = false;
                                    DeselectNode(GraphEditor.hover_node);
                                    current.Use();
                                }
                                else
                                {
                                    GraphEditor.can_drag_node = true;
                                    SelectNode(GraphEditor.hover_node);
                                    current.Use();
                                }
                            }
                            else
                            {
                                if (GraphEditor.hover_node.is_selected)
                                {
                                    GraphEditor.can_drag_node = true;
                                }
                                else
                                {
                                    GraphEditor.can_drag_node = true;
                                    SelectOnlyNode(GraphEditor.hover_node);
                                    current.Use();
                                }
                            }
                        }
                    }
                    else if (editable_area.Contains(GraphEditor.mouse_position))
                    {
                        GraphEditor.can_select = true;
                    }
                    break;

                case 1:
                    break;

                case 2:
                    break;
                }
                break;

            case EventType.MouseUp:
                switch (current.button)
                {
                case 0:
                    if (GraphEditor.can_select && GraphEditor.is_select)
                    {
                        Rect        select_box_in_scroll = new Rect(select_box.position / target_zoom, select_box.size / target_zoom);
                        List <Node> nodes = GraphEditor.graph.nodes.Where((n) => select_box_in_scroll.Overlaps(n.nodeRect)).ToList();
                        if (current.shift)
                        {
                            foreach (Node node in nodes)
                            {
                                if (node.is_selected)
                                {
                                    DeselectNode(node);
                                }
                                else
                                {
                                    SelectNode(node);
                                }
                            }
                            current.Use();
                        }
                        else
                        {
                            ClearSelection();
                            SelectNodes(nodes);
                            current.Use();
                        }
                    }
                    else
                    {
                        if (GraphEditor.hover_node)
                        {
                            if (GraphEditor.is_drag)
                            {
                                if (GraphEditor.drag_port)
                                {
                                    if (GraphEditor.hover_port)
                                    {
                                        PlugPort(GraphEditor.drag_port, GraphEditor.hover_port);
                                    }
                                    else
                                    {
                                        QuickPlugPort(GraphEditor.drag_port, GraphEditor.hover_node);
                                    }
                                    current.Use();
                                }
                            }
                            else
                            {
                                if (!current.shift)
                                {
                                    if (GraphEditor.selection.Count > 1)
                                    {
                                        SelectOnlyNode(GraphEditor.hover_node);
                                        current.Use();
                                    }
                                }
                            }
                        }
                        else if (!GraphEditor.is_scrolling)
                        {
                            ClearSelection();
                        }
                        if (GraphEditor.drag_port && !GraphEditor.hover_node)
                        {
                            InputAction  in_act    = GraphEditor.drag_port as InputAction;
                            OutputAction out_act   = GraphEditor.drag_port as OutputAction;
                            IInputValue  in_value  = GraphEditor.drag_port as IInputValue;
                            IOutputValue out_value = GraphEditor.drag_port as IOutputValue;
                            if (in_act != null)
                            {
                                GraphEditor.waiting_for_new_node = true;
                                AdvancedSearchWindow.Init(GraphEditor.mouse_position, "#tag:in void");
                            }
                            else if (out_act != null)
                            {
                                GraphEditor.waiting_for_new_node = true;
                                AdvancedSearchWindow.Init(GraphEditor.mouse_position, "#tag:out void");
                            }
                            else if (in_value != null)
                            {
                                GraphEditor.waiting_for_new_node = true;
                                AdvancedSearchWindow.Init(GraphEditor.mouse_position, "#tag:out " + in_value.valueType.GetTypeName(false, true));
                            }
                            else if (out_value != null)
                            {
                                GraphEditor.waiting_for_new_node = true;
                                AdvancedSearchWindow.Init(GraphEditor.mouse_position, "#tag:in " + out_value.valueType.GetTypeName(false, true));
                            }
                        }
                    }
                    GraphEditor.can_select   = false;
                    GraphEditor.is_select    = false;
                    GraphEditor.is_scrolling = false;
                    GraphEditor.hover_node   = null;
                    GraphEditor.drag_node    = null;
                    if (!GraphEditor.waiting_for_new_node)
                    {
                        GraphEditor.is_drag       = false;
                        GraphEditor.drag_port     = null;
                        GraphEditor.can_drag_port = false;
                    }
                    GraphEditor.can_drag_node = false;
                    break;

                case 1:
                    if (!GraphEditor.is_drag)
                    {
                        AdvancedSearchWindow.Init(GraphEditor.mouse_position);
                        current.Use();
                    }
                    GraphEditor.is_drag = false;
                    break;

                case 2:
                    break;
                }
                break;

            case EventType.MouseDrag:
                switch (current.button)
                {
                case 0:
                    if (current.alt)
                    {
                        GraphEditor.is_drag      = true;
                        GraphEditor.is_scrolling = true;
                        GraphEditor.scroll      += delta;
                        break;
                    }
                    if (!GraphEditor.is_drag)
                    {
                        if (GraphEditor.can_drag_port && GraphEditor.hover_port)
                        {
                            GraphEditor.is_drag       = true;
                            GraphEditor.can_drag_node = false;
                            GraphEditor.drag_port     = GraphEditor.hover_port;
                        }
                        if (GraphEditor.can_drag_node && GraphEditor.hover_node)
                        {
                            GraphEditor.is_drag       = true;
                            GraphEditor.can_drag_port = false;
                            GraphEditor.drag_node     = GraphEditor.hover_node;
                        }
                    }
                    // ...
                    if (GraphEditor.is_drag)
                    {
                        if (GraphEditor.drag_node)
                        {
                            foreach (Node node in GraphEditor.selection)
                            {
                                node.position += delta;
                            }
                        }
                    }
                    else
                    {
                        if (GraphEditor.can_select)
                        {
                            GraphEditor.is_select = true;
                        }
                    }
                    break;

                case 1:
                    GraphEditor.is_drag      = true;
                    GraphEditor.is_scrolling = true;
                    GraphEditor.scroll      += delta;
                    break;

                case 2:
                    GraphEditor.is_drag      = true;
                    GraphEditor.is_scrolling = true;
                    GraphEditor.scroll      += delta;
                    break;
                }
                break;

            case EventType.ScrollWheel:
                if (!GraphEditor.is_drag)
                {
                    float zoom_delta = 0.1f;
                    zoom_delta   = current.delta.y < 0.0f ? zoom_delta : -zoom_delta;
                    target_zoom += zoom_delta;
                    target_zoom  = Mathf.Clamp(target_zoom, 0.2f, 1.0f);
                }
                break;

            case EventType.ValidateCommand:
                switch (Event.current.commandName)
                {
                case ("Delete"):
                    DeleteSelectedNodes();
                    current.Use();
                    break;

                case ("Duplicate"):
                    DuplicateSelectedNodes();
                    current.Use();
                    break;

                case ("SelectAll"):
                    if (GraphEditor.selection.Count == GraphEditor.graph.nodeCount)
                    {
                        ClearSelection();
                        current.Use();
                    }
                    else
                    {
                        SelectNodes(GraphEditor.graph.nodes);
                        current.Use();
                    }
                    break;
                }
                break;

            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (DragAndDrop.objectReferences.Length > 0)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    if (current.type == EventType.DragPerform)
                    {
                        DragAndDrop.AcceptDrag();
                        GenericMenu generic_menu = new GenericMenu();
                        Type        type;
                        string      type_name;
                        foreach (UnityObject drag_obj in DragAndDrop.objectReferences)
                        {
                            if (drag_obj == null)
                            {
                                continue;
                            }
                            if (drag_obj is GraphAsset)
                            {
                                GraphAsset m_asset = (GraphAsset)drag_obj;
                                if (m_asset)
                                {
                                    generic_menu.AddItem(new GUIContent(string.Format("Add {0} as Macro", m_asset.title.IsNullOrEmpty() ? m_asset.name : m_asset.title)), false, (obj) => {
                                        AddMacro(m_asset, (Vector2)obj);
                                    }, GraphEditor.mouse_position - GraphEditor.scroll);
                                }
                            }
                            else if (drag_obj is MonoScript)
                            {
                                MonoScript script = (MonoScript)drag_obj;
                                if (script)
                                {
                                    type      = script.GetClass();
                                    type_name = type.GetTypeName();

                                    generic_menu.AddItem(new GUIContent(string.Format("{0}/Expose {0} members", type_name)), false, (obj) => {
                                        AddCustomNode <ReflectedObjectNode>((Vector2)obj, true, type);
                                    }, GraphEditor.mouse_position - GraphEditor.scroll);
                                    generic_menu.AddSeparator(string.Format("{0}/", type_name));

                                    AddTypeMethodsToMenu(generic_menu, type, type_name);

                                    if (type.IsSubclassOf(typeof(Node)) && !type.IsAbstract && !type.IsGenericType)
                                    {
                                        generic_menu.AddItem(new GUIContent(string.Format("Add {0} as Node", type_name)), false, (obj) => {
                                            AddNode(type, (Vector2)obj);
                                        }, GraphEditor.mouse_position - GraphEditor.scroll);
                                    }
                                }
                            }

                            if (drag_obj is GraphAsset || drag_obj is MonoScript)
                            {
                                generic_menu.AddSeparator("");
                            }

                            type      = drag_obj.GetType();
                            type_name = type.GetTypeName();

                            generic_menu.AddItem(new GUIContent(string.Format("Expose {0} members", type_name)), false, (obj) => {
                                AddCustomNode <ReflectedObjectNode>((Vector2)obj, true, type);
                            }, GraphEditor.mouse_position - GraphEditor.scroll);

                            AddTypeMethodsToMenu(generic_menu, type, type_name);
                        }
                        DragAndDrop.PrepareStartDrag();
                        generic_menu.ShowAsContext();
                    }
                }
                break;

            case (EventType.KeyDown):
                switch (current.keyCode)
                {
                case KeyCode.Space:
                    if (!current.control)
                    {
                        AdvancedSearchWindow.Init(position.size / 2.0f);
                        current.Use();
                    }
                    break;

                case KeyCode.Delete:
                    DeleteSelectedNodes();
                    current.Use();
                    break;

                case KeyCode.Home:
                    target_zoom        = 1.0f;
                    GraphEditor.scroll = Vector2.zero;
                    current.Use();
                    break;

                case KeyCode.PageDown:
                    GraphEditor.scroll -= new Vector2(0.0f, position.height);
                    current.Use();
                    break;

                case KeyCode.PageUp:
                    GraphEditor.scroll += new Vector2(0.0f, position.height);
                    current.Use();
                    break;
                }
                break;
            }
        }
Esempio n. 27
0
        public void SetMethod(MethodInfo method_info, params Type[] type_args)
        {
            if (method_info == null)
            {
#if UNITY_EDITOR
                node_color = Color.red;
                DisplayMessage("Missing Method", UnityEditor.MessageType.Error);
#endif
                Debug.LogError("type method_info is null!");
                return;
            }

            this.cached_method = method_info;

            if (type_args.IsNullOrEmpty())
            {
                this.serialized_method = this.serialized_method ?? new SerializedMethod(method_info);
            }
            else
            {
                this.serialized_method = this.serialized_method ?? new SerializedMethod(method_info, type_args);
            }

            string method_name = cached_method.Name;
            this.name = method_name;

            RegisterEntryPort("In", Execute);
            this.output = RegisterExitPort("Out");

            if (method_info.ReturnType != typeof(void))
            {
                RegisterOutputValue(method_info.ReturnType, "Get", Invoke);
            }
#if UNITY_EDITOR
            node_color = GUIReferrer.GetTypeColor(method_info.ReturnType);

            ObsoleteAttribute obsolete_flag = method_info.GetAttribute <ObsoleteAttribute>(false);
            if (obsolete_flag != null)
            {
                DisplayMessage(obsolete_flag.Message, UnityEditor.MessageType.Warning);
            }
#endif

            if (method_info.IsStatic)
            {
                this.target = null;
                string title = method_name;
                if (title.Contains("get_"))
                {
                    title = title.Replace("get_", string.Empty);
                }
                else if (title.Contains("set_"))
                {
                    title = title.Replace("set_", string.Empty);
                }
                this.title = title;
            }
            else
            {
                this.target = (IInputValue)RegisterInputValue(method_info.ReflectedType, "Target");
                string title = method_name;
                if (title.Contains("get_"))
                {
                    title = /*"[Get] " + */ title.Replace("get_", string.Empty).AddSpacesToSentence();
                }
                else if (title.Contains("set_"))
                {
                    title = /*"[Set] " + */ title.Replace("set_", string.Empty).AddSpacesToSentence();
                }
                this.title = title;
            }

            parameters = new List <IInputValue>();
            foreach (ParameterInfo parameter in method_info.GetParameters())
            {
                parameters.Add((IInputValue)RegisterInputValue(parameter.ParameterType, parameter.Name.AddSpacesToSentence()));
            }
        }
Esempio n. 28
0
        private void StartProgramWithWaitForExit(
            ISpecialExecutionTaskTestAction testAction,
            IParameter exitParameter,
            ProcessStartInfo processStartInfo,
            IParameter pathParameter,
            string expandedPath,
            string processArguments)
        {
            if (exitParameter.GetAsInputValue().Verify("True", exitParameter.Operator) is FailedActionResult)
            {
                throw new InvalidOperationException(
                          "Please use 'True' as value for " + exitParameter.Name
                          + ". If you don't want to wait for exit of the application, please delete the node. The items below won't work without waiting for exit.");
            }
            IParameter stdoutParameter   = exitParameter.GetChildParameter(StandardOutputFile, true);
            IParameter exitCodeParameter = exitParameter.GetChildParameter(
                ProcessExitCode,
                true,
                new[] { ActionMode.Buffer, ActionMode.Verify });
            IInputValue timeoutForExitValue = exitParameter.GetChildParameterAsInputValue(TimeoutForExit, true);

            int timeoutForExit;

            if (timeoutForExitValue != null)
            {
                if (!int.TryParse(timeoutForExitValue.Value, out timeoutForExit))
                {
                    throw new InvalidOperationException(
                              "Please use a valid integer value for the Parameter 'TimeoutForExit'");
                }
                timeoutForExit = timeoutForExit * 1000;
            }
            else
            {
                timeoutForExit = int.MaxValue;
            }
            string output;

            try {
                int       exitCode;
                bool      wasTimeout;
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                output = StartProcessWithWaitForExit(
                    processStartInfo,
                    stdoutParameter != null,
                    timeoutForExit,
                    out exitCode,
                    out wasTimeout);
                stopwatch.Stop();
                testAction.SetResult(
                    SpecialExecutionTaskResultState.Ok,
                    string.Format("Started '{0}' with arguments '{1}'", expandedPath, processArguments));
                if (wasTimeout)
                {
                    testAction.SetResultForParameter(
                        pathParameter,
                        SpecialExecutionTaskResultState.Failed,
                        string.Format(
                            "Timeout occured, process didn't stop within the timeout of {0} seconds!",
                            timeoutForExit / 1000));
                }
                else
                {
                    testAction.SetResultForParameter(
                        pathParameter,
                        SpecialExecutionTaskResultState.Ok,
                        string.Format(
                            "Process stopped after '{0}' minutes.",
                            Math.Round(stopwatch.Elapsed.TotalMinutes)));
                    if (exitCodeParameter != null)
                    {
                        HandleActualValue(testAction, exitCodeParameter, exitCode);
                    }
                }
            }
            catch (Win32Exception e) {
                testAction.SetResultForParameter(
                    pathParameter,
                    SpecialExecutionTaskResultState.Failed,
                    CreateMessageForStartError(expandedPath, processArguments, e),
                    e.StackTrace,
                    "");
                return;
            }
            if (stdoutParameter != null && output != null)
            {
                String filePath = Environment.ExpandEnvironmentVariables(stdoutParameter.GetAsInputValue().Value);
                File.WriteAllText(filePath, output);
                testAction.SetResultForParameter(
                    stdoutParameter,
                    new PassedActionResult(
                        "The Standard-Output was saved inside the given file. See 'Details'-column for the path.",
                        filePath,
                        String.Empty));
            }
        }
Esempio n. 29
0
        public void EDITOR_DrawNode()
        {
            if (!is_ready)
            {
                return;
            }
            gui_color         = GUI.color;
            gui_back_color    = GUI.backgroundColor;
            gui_content_color = GUI.contentColor;

            if (is_active || is_selected || GraphEditor.hover_node == this || (GraphEditor.drag_port && GraphEditor.drag_port.node == this))
            {
            }
            else
            {
                GUI.color = new Color(gui_color.r, gui_color.g, gui_color.b, 0.5f);
            }

            // for better performance
            if (is_occluded)
            {
                foreach (Port port in portValues)
                {
                    if (!port.display_port)
                    {
                        continue;
                    }
                    IPlugIn plug_in = port as IPlugIn;
                    if (plug_in == null || !plug_in.IsPlugged())
                    {
                        continue;
                    }
                    port.node = this;

                    Vector2 start = GetPortPoint(port).center;
                    Vector2 end   = GetPortPoint((Port)plug_in.GetPluggedPort()).center;
                    if (port is ActionPort)
                    {
                        end   = GetPortPoint(port).center;
                        start = GetPortPoint((Port)plug_in.GetPluggedPort()).center;
                    }

                    Node.DrawConnection(start, end, GetPortColor(port), false);
                    if (Application.isPlaying)
                    {
                        if (port.flow_state == FlowState.Active)
                        {
                            port.unit_delta_size = 1.0f;
                            port.flow_state      = FlowState.Idle;
                        }
                        else
                        {
                            port.unit_delta_size = Mathf.MoveTowards(port.unit_delta_size, 0.0f, EditorTime.deltaTime / 2.0f);
                        }

                        GUI.backgroundColor = GetPortColor(port);
                        float distance = FPMath.SnapValue(Vector3.Distance(start, end) / 100.0f, 1);
                        for (int id = 0; id < Mathf.RoundToInt(distance); id++)
                        {
                            float   t         = 1.0f - (((EditorTime.time / distance) + (1.0f / distance) * id) % 1.0f);
                            Vector2 unit_size = V2x16y16 * port.unit_delta_size;
                            GUI.Box(new Rect(LerpUnit(start, end, t) - V2x0y2 - unit_size / 2.0f, unit_size), "", styles.unit);
                        }
                        GUI.backgroundColor = gui_back_color;
                    }
                    else
                    {
                        if (GUI.Button(new Rect(MiddleOfConnection(end, start) - V2x8y9, V2x16y16), "x", styles.unplug_button))
                        {
                            GraphEditor.UnplugPort(port);
                        }
                    }
                }
            }
            else
            {
                if (is_selected)
                {
                    GUI.Box(nodeRect, string.Empty, styles.highlight_node);
                }

                is_active = GraphEditor.makeAllNodesActive || this is EventNode || this is InputNode || this is OutputNode;
                //Draw Node with custom color
                GUI.backgroundColor = node_color;
                if (slim)
                {
                    DrawSlimNode();
                }
                else
                {
                    DrawNode();
                }
                GUI.backgroundColor = gui_back_color;

                // Color gui_color = GUI.color;
                foreach (Port input in inputValues)
                {
                    input.node = this;
                    if (!input.display_port)
                    {
                        continue;
                    }
                    IPlug       plug        = input as IPlug;
                    IPlugIn     plug_in     = input as IPlugIn;
                    bool        on          = plug != null && plug.IsPlugged();
                    IInputValue input_value = input as IInputValue;
                    Rect        port_rect   = GetPortPoint(input);

                    if (plug_in != null)
                    {
                        if (plug_in.IsPlugged())
                        {
                            Vector2 start = port_rect.center;
                            Vector2 end   = GetPortPoint((Port)plug_in.GetPluggedPort()).center;

                            Node.DrawConnection(start, end, GetPortColor(input), false);

                            if (Application.isPlaying)
                            {
                                if (input.flow_state == FlowState.Active)
                                {
                                    input.unit_delta_size = 1.0f;
                                    input.flow_state      = FlowState.Idle;
                                }
                                else
                                {
                                    input.unit_delta_size = Mathf.MoveTowards(input.unit_delta_size, 0.0f, EditorTime.deltaTime / 2.0f);
                                }

                                GUI.backgroundColor = GetPortColor(input);
                                float distance = FPMath.SnapValue(Vector3.Distance(start, end) / 100.0f, 1);
                                for (int id = 0; id < Mathf.RoundToInt(distance); id++)
                                {
                                    float   t         = 1.0f - (((EditorTime.time / distance) + (1.0f / distance) * id) % 1.0f);
                                    Vector2 unit_size = V2x16y16 * input.unit_delta_size;
                                    GUI.Box(new Rect(LerpUnit(start, end, t) - V2x0y2 - unit_size / 2.0f, unit_size), "", styles.unit);
                                }
                                GUI.backgroundColor = gui_back_color;
                            }
                            else
                            {
                                if (GUI.Button(new Rect(MiddleOfConnection(start, end) - V2x8y9, V2x16y16), "x", styles.unplug_button))
                                {
                                    GraphEditor.UnplugPort(input);
                                }
                            }
                        }
                        else if (input_value != null)
                        {
                            if (GraphEditor.showPortValues)
                            {
                                object value = input_value.GetDefaultValue();
                                Rect   value_label_rect;
                                string value_content     = "NO INFO";
                                float  value_label_width = 0.0f;
                                if (value == null)
                                {
                                    if (typeof(UnityEngine.Component).IsAssignableFrom(input_value.valueType) || typeof(Graph).IsAssignableFrom(input_value.valueType) || typeof(UnityEngine.GameObject).IsAssignableFrom(input_value.valueType))
                                    {
                                        if (EditorGUIUtility.isProSkin)
                                        {
                                            value_content = string.Format("<b><color=#0667FF>SELF: {0}</color></b>", input_value.valueType.GetTypeName());
                                        }
                                        else
                                        {
                                            value_content = string.Format("<b><color=#458fff>SELF: {0}</color></b>", input_value.valueType.GetTypeName());
                                        }
                                    }
                                    else
                                    {
                                        value_content = input_value.valueType.GetTypeName(true);
                                    }
                                }
                                else
                                {
                                    if (typeof(string).IsAssignableFrom(input_value.valueType))
                                    {
                                        value_content = string.Format("<color=#FFA06396>\"{0}\"</color>", value);
                                    }
                                    else if (typeof(UnityEngine.Component).IsAssignableFrom(input_value.valueType) || typeof(UnityEngine.GameObject).IsAssignableFrom(input_value.valueType) || typeof(Graph).IsAssignableFrom(input_value.valueType))
                                    {
                                        value_content = string.Format("<b><color=#0667FF>{0}</color></b>", value);
                                    }
                                    else if (typeof(Type).IsAssignableFrom(input_value.valueType))
                                    {
                                        value_content = ReflectionUtils.GetTypeName((Type)value, true);
                                    }
                                    else
                                    {
                                        if (input_value.valueType.IsGenericType)
                                        {
                                            value_content = input_value.valueType.GetTypeName(true);
                                        }
                                        else
                                        {
                                            value_content = value.ToString();
                                        }
                                    }
                                }
                                value_label_width = GUIUtils.GetTextWidth(value_content, styles.input_label);
                                value_label_rect  = new Rect(port_rect.x - (value_label_width + 15.0f), port_rect.y, value_label_width, 18.0f);
                                GUI.Label(value_label_rect, value_content, styles.input_label);
                            }
                        }
                    }

                    port_rect = GraphEditor.ZoomedRect(GetPortPoint(input));
                    if (port_rect.Contains(GraphEditor.mouse_position))
                    {
                        GraphEditor.hover_port = input;
                    }
                    else
                    {
                        GUI.backgroundColor = GetPortColor(input);
                    }
                    port_rect = GetPortPoint(input);

                    if (input is ActionPort)
                    {
                        if (!is_active && ((IPlug)input).IsPlugged())
                        {
                            List <IPlugIn> list = ((IPlugOut)input).GetPluggedPorts();
                            if (list != null && list.Any(p => ((Port)p).node && ((Port)p).node.is_active))
                            {
                                is_active = true;
                            }
                        }
                        GUI.Box(port_rect, slim ? string.Empty : input.name, on ? styles.on_input_action : styles.input_action);
                    }
                    else
                    {
                        GUI.Box(port_rect, slim ? string.Empty : input.name, on ? styles.on_input_port : styles.input_port);
                    }

                    GUI.backgroundColor = gui_back_color;
                }

                foreach (Port output in outputValues)
                {
                    output.node = this;
                    if (!output.display_port)
                    {
                        continue;
                    }
                    IPlug   plug      = output as IPlug;
                    IPlugIn plug_in   = output as IPlugIn;
                    bool    on        = plug != null && plug.IsPlugged();
                    Rect    port_rect = GetPortPoint(output);

                    if (plug_in != null)
                    {
                        if (plug_in.IsPlugged())
                        {
                            Vector2 start = port_rect.center;
                            Vector2 end   = GetPortPoint((Port)plug_in.GetPluggedPort()).center;

                            Node.DrawConnection(end, start, GetPortColor(output), false);

                            if (Application.isPlaying)
                            {
                                if (output.flow_state == FlowState.Active)
                                {
                                    output.unit_delta_size = 1.0f;
                                    output.flow_state      = FlowState.Idle;
                                }
                                else
                                {
                                    output.unit_delta_size = Mathf.MoveTowards(output.unit_delta_size, 0.0f, EditorTime.deltaTime / 2.0f);
                                }

                                float distance = FPMath.SnapValue(Vector3.Distance(start, end) / 100.0f, 1);
                                GUI.backgroundColor = GetPortColor(output);
                                for (int id = 0; id < Mathf.RoundToInt(distance); id++)
                                {
                                    float   t         = 1.0f - (((EditorTime.time / distance) + (1.0f / distance) * id) % 1.0f);
                                    Vector2 unit_size = V2x16y16 * output.unit_delta_size;
                                    GUI.Box(new Rect(LerpUnit(end, start, t) - V2x0y2 - unit_size / 2.0f, unit_size), "", styles.unit);
                                }
                                GUI.backgroundColor = gui_back_color;
                            }
                            else
                            {
                                if (GUI.Button(new Rect(MiddleOfConnection(start, end) - V2x8y9, V2x16y16), "x", styles.unplug_button))
                                {
                                    GraphEditor.UnplugPort(output);
                                }
                            }
                        }
                    }
                    port_rect = GraphEditor.ZoomedRect(GetPortPoint(output));
                    if (port_rect.Contains(GraphEditor.mouse_position))
                    {
                        GraphEditor.hover_port = output;
                    }
                    else
                    {
                        GUI.backgroundColor = GetPortColor(output);
                    }
                    port_rect = GetPortPoint(output);

                    if (output is ActionPort)
                    {
                        GUI.Box(port_rect, slim ? string.Empty : output.name, on ? styles.on_output_action : styles.output_action);
                    }
                    else
                    {
                        if (!is_active && ((IPlug)output).IsPlugged() && ((IPlugOut)output).GetPluggedPorts().Any(p => ((Port)p).node.is_active))
                        {
                            is_active = true;
                        }
                        GUI.Box(port_rect, slim ? string.Empty : output.name, on ? styles.on_output_port : styles.output_port);
                    }
                    GUI.backgroundColor = gui_back_color;
                }
                GUI.backgroundColor = gui_back_color;
            }
            GUI.color           = gui_color;
            GUI.backgroundColor = gui_back_color;
            GUI.contentColor    = gui_content_color;
        }