public async Task Invalid_return_type_on_method_fails_to_execute(string methodName) { var cSource = new CancellationTokenSource(TimeSpan.FromSeconds(3)); string actualMethodName = null; var scriptEventResult = ScriptEventResult.Successful(); await Task.Run(() => { var sciterWindow = new SciterWindow() .CreateMainWindow(320, 240) .CenterWindow() .SetTitle(nameof(SciterGraphicsTests)); var host = new TestHost(sciterWindow); host.AttachEventHandler(() => new TestEventHandler( onScriptCallCallback: (element, info, args, result) => { actualMethodName = info.Name; scriptEventResult = result; sciterWindow?.Close(); })); var pageData = "<html><head><style></style>" + "<script type=\"text/tiscript\"> " + $"view.{methodName}();" + "</script>" + "</head></html>"; host.Window.LoadHtml(pageData); host.Window.Show(); TranslateAndDispatch(cSource.Token); }, cSource.Token); Assert.NotNull(actualMethodName); Assert.AreEqual(methodName, actualMethodName); Assert.IsFalse(scriptEventResult.IsSuccessful); Assert.IsNull(scriptEventResult.Value); Assert.IsFalse(cSource.IsCancellationRequested); }
public async Task Ensure_the_function_is_executed_when_the_page_loads(string methodName) { var cSource = new CancellationTokenSource(TimeSpan.FromSeconds(3)); string actualMethodName = null; await Task.Run(() => { var sciterWindow = new SciterWindow() .CreateMainWindow(320, 240) .CenterWindow() .SetTitle(nameof(SciterGraphicsTests)); var host = new TestHost(sciterWindow); host.AttachEventHandler(() => new TestEventHandler( (element, info, args, result) => { actualMethodName = info.Name; }, (window) => { window?.Close(); })); var pageData = "<html><head><style></style>" + "<script type=\"text/tiscript\"> " + "function self.ready() {" + $"view.{methodName}();" + "}" + "</script>" + "</head></html>"; host.Window.LoadHtml(pageData); host.Window.Show(); TranslateAndDispatch(cSource.Token); }, cSource.Token); Assert.NotNull(actualMethodName); Assert.AreEqual(methodName, actualMethodName); Assert.IsFalse(cSource.IsCancellationRequested); }