public static object RunTest(String address, String entryPoint, String fileName, string reportath, string resourcePath) { object result = null; if (File.Exists(fileName)) { using (Stream scriptStream = File.OpenRead(fileName)) { Engine = BitMobile.Script.ScriptEngine.LoadScript(scriptStream, entryPoint, DateTime.Now); Console console = new Console(reportath, Engine); Engine.AddVariable("Console", console); Engine.AddVariable("Device", new Device(address, console, resourcePath)); Engine.AddVariable("Stopwatch", new Stopwatch()); Engine.AddVariable("Dialog", new Dialog(address, console)); result = Engine.CallFunction(entryPoint); } return(result); } else { throw new Exception("Test file does not exist"); } }
public static object RunTest(String address, String entryPoint, String fileName, string reportath, string resourcePath) { object result = null; if (File.Exists(fileName)) { using (Stream scriptStream = File.OpenRead(fileName)) { Engine = BitMobile.Script.ScriptEngine.LoadScript(scriptStream, entryPoint, DateTime.Now); Console console = new Console(reportath, Engine); Engine.AddVariable("Console", console); Engine.AddVariable("Device", new Device(address, console, resourcePath)); Engine.AddVariable("Stopwatch", new Stopwatch()); Engine.AddVariable("Dialog", new Dialog(address, console)); result = Engine.CallFunction(entryPoint); } return result; } else throw new Exception("Test file does not exist"); }
public object CallFunction(string moduleName, string functionName, object[] parameters) { ScriptEngine engine = this; if (!String.IsNullOrEmpty(moduleName)) { if (!moduleName.EndsWith(".js")) { moduleName = moduleName + ".js"; } if (!scripts.ContainsKey(moduleName)) { if (ModuleResolver != null) { engine = ModuleResolver(moduleName); } if (engine == null) { throw new Exception(String.Format("Invalid module name '{0}'", moduleName)); } } else { engine = scripts[moduleName]; } } try { return(engine.CallFunction(functionName, parameters)); } catch (Exception e) { throw new Exception(String.Format("{0}:{1}", e.Message, this.CurrentLine)); } }