public void GlobalTestSetup() { Trace.WriteLine("Environment is " + (Environment.Is64BitProcess ? "64bit" : "32bit")); this.WScript = new SimpleHostObject(); this.scriptEngine = new ActiveScriptEngine(progID); this.scriptEngine.ScriptErrorOccurred += scriptEngine_ScriptErrorOccurred; this.scriptEngine.AddObject("WScript", this.WScript); this.script = this.scriptEngine.GetScriptHandle(); this.expectedError = null; }
protected void scriptEngine_ScriptErrorOccurred(ActiveScriptEngine sender, ScriptErrorInfo error) { Trace.WriteLine(error.DebugDump()); if (expectedError == null) { Assert.Fail("Script threw an unexpected error"); } else { CheckErrors(expectedError, error); } }
public static void CheckErrors(ScriptErrorInfo expected, ScriptErrorInfo actual) { Assert.AreEqual(expected.ErrorNumber, actual.ErrorNumber); if (expected.ColumnNumber != 0) { Assert.AreEqual(expected.ColumnNumber, actual.ColumnNumber); } if (expected.LineNumber != 0) { Assert.AreEqual(expected.LineNumber, actual.LineNumber); } if (!string.IsNullOrEmpty(expected.ScriptName)) { Assert.AreEqual(expected.ScriptName, actual.ScriptName); } }