Пример #1
0
        public void ExecuteActScriptAction(string ScriptFileName, string SolutionFolder)
        {
            //TODO: Remove from here and execute it in actual RunSetActionScript.cs (Not perticularly tested)
            ActScript act = new ActScript();
            //string FileName = ScriptFileName.Replace(@"~\", SolutionFolder);
            string FileName = amdocs.ginger.GingerCoreNET.WorkSpace.Instance.SolutionRepository.ConvertSolutionRelativePath(ScriptFileName);

            Ginger.Run.RunSetActions.RunSetActionScript actionScript = new RunSetActionScript();
            actionScript.VerifySolutionFloder(SolutionFolder, FileName);

            act.ScriptName            = FileName;
            act.ScriptInterpreterType = ActScript.eScriptInterpreterType.VBS;
            act.Execute();
            //this.Errors = act.Error;
        }
Пример #2
0
        [TestMethod]  //[Timeout(60000)]
        public void FreeCommandBAT()
        {
            // Arrange
            ActScript v = new ActScript();

            v.ScriptInterpreterType = ActScript.eScriptInterpreterType.BAT;
            v.ScriptCommand         = ActScript.eScriptAct.FreeCommand;
            v.AddNewReturnParams    = true;
            v.AddOrUpdateInputParamCalculatedValue("Free Command", "@echo off \r\nSET /A a = 5 \r\nSET /A b = 10 \r\nSET /A c = %a% + %b% \r\necho Add=%c% ");

            //Act
            v.Execute();

            //Assert
            Assert.AreEqual(v.Error, null);
            Assert.AreEqual(v.ReturnValues[0].Actual.Contains("Add=15"), true);
        }
Пример #3
0
 public void Execute(IReportInfo RI)
 {
     try
     {
         ActScript act      = new ActScript();
         string    FileName = WorkSpace.Instance.Solution.SolutionOperations.ConvertSolutionRelativePath(RunSetActionScript.ScriptFileName);
         VerifySolutionFloder(RunSetActionScript.SolutionFolder, FileName);
         act.ScriptName            = FileName;
         act.ScriptInterpreterType = (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
             ? ActScript.eScriptInterpreterType.VBS : ActScript.eScriptInterpreterType.SH;
         act.Execute();
     }
     catch (Exception ex)
     {
         RunSetActionScript.Errors = ex.Message.ToString();
         RunSetActionScript.Status = eRunSetActionStatus.Failed;
     }
 }
Пример #4
0
        public void FreeCommandVBS()
        {
            if (!isOSWindows)
            {
                return;
            }
            ActScript v = new ActScript();

            v.ScriptInterpreterType = ActScript.eScriptInterpreterType.VBS;
            v.ScriptCommand         = ActScript.eScriptAct.FreeCommand;
            v.AddNewReturnParams    = true;
            v.AddOrUpdateInputParamCalculatedValue("Free Command", "NumberB=10\r\nNumberA=20\r\nDim Result\r\nResult= int(NumberA) + int(NumberB)\r\nWscript.Echo \"Add=\" & Result");

            v.Execute();

            Assert.AreEqual(v.Error, null);
            Assert.AreEqual(v.ReturnValues[0].Actual.Contains("Add=30"), true);
        }
Пример #5
0
        public static string ExecuteVBSEval(string Expr)
        {
            //Create temp vbs file
            string fileName = "";

            try
            {
                fileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".vbs";
            }catch (Exception)
            {
                //this to overcome speical IT settings which doesn't allow local personal folders
                fileName = "" + Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) + @"\" + Guid.NewGuid().ToString() + ".vbs" + "";
            }
            string s = "Dim v" + Environment.NewLine;

            s += "v=" + Expr.Replace("\r\n", "vbCrLf").Replace("\n", "vbCrLf").Replace("\r", "vbCrLf") + Environment.NewLine;
            s += "Wscript.echo v" + Environment.NewLine;
            System.IO.File.WriteAllText(fileName, s);
            //Execute
            ActScript scr = new ActScript();

            scr.AddNewReturnParams = true;
            scr.ScriptCommand      = ActScript.eScriptAct.Script;
            scr.ScriptName         = fileName;

            scr.Execute();

            //Delete the temp vbs file
            System.IO.File.Delete(fileName);

            //Return the result
            string result = scr.ReturnValues[0].Actual;

            if (result != null)
            {
                result = result.Trim();
            }

            return(result);
        }
Пример #6
0
        public void RunScriptAPlusBBAT()
        {
            // Arrange
            ActScript v = new ActScript();

            v.ScriptInterpreterType = ActScript.eScriptInterpreterType.BAT;
            v.AddNewReturnParams    = true;
            v.ScriptCommand         = ActScript.eScriptAct.Script;
            v.AddOrUpdateInputParamCalculatedValue("p1", "5");
            v.AddOrUpdateInputParamCalculatedValue("p2", "7");

            v.ScriptName = "BatchScriptWithArgs.bat";
            v.ScriptPath = TestResources.GetTestResourcesFolder("");

            //Act
            v.Execute();

            //Assert
            Assert.AreEqual(v.Error, null);

            Assert.AreEqual(v.ReturnValues[0].Param, "Result");
            Assert.AreEqual(v.ReturnValues[0].Actual, "12");
        }