private static string getScriptEditor(string filename) { var ascxSourceCodeEditor = getScriptEditorControlName(filename); if (false == O2AscxGUI.isAscxLoaded(ascxSourceCodeEditor)) { O2AscxGUI.openAscx(typeof(ascx_SourceCodeEditor), O2DockState.Document, ascxSourceCodeEditor); } return(ascxSourceCodeEditor); }
public void openGui() { // use this to use the main O2 GUi /* O2AscxGUI.launch(); * O2AscxGUI.openAscx(typeof (ascx_SourceCodeEditor), O2DockState.Document,sourceCodeEditorControl); */ // use this to only open the ascx_SourceCodeEditor control O2AscxGUI.openAscxAsForm(typeof(ascx_SourceCodeEditor), sourceCodeEditorControl); Assert.That(O2AscxGUI.isAscxLoaded(sourceCodeEditorControl), "sourceCodeEditorControl was not loaded"); //sourceCodeEditorControl.invokeOnAscx("loadSampleScripts", new object[] {typeof (OzasmtScriptSamples)}); // Assert.That(((List<string>)sourceCodeEditorControl.invokeOnAscx("getSampleScriptsNames")).Count > 0, "getSampleScriptsNames.Count == 0 "); O2AscxGUI.invokeOnAscxControl(sourceCodeEditorControl, "loadSourceCodeFile", new object[] { hardCodedPathToSampleScriptToEdit }); //Processes.Sleep(1000); /*var sourceCodeFromAscxControl = (string) O2AscxGUI.invokeOnAscxControl(sourceCodeEditorControl, "getSourceCode"); * Assert.That(sourceCodeFromAscxControl == OzasmtScriptSamples._1_OzamtManipulation, * "Source code was not correctly loaded");*/ }
public void loadTestGui() { // lauch Gui O2AscxGUI.launch(); DI.log.LogRedirectionTarget = null; // so that we get all DI.log messages O2AscxGUI.setLogViewerDockState(O2DockState.DockBottom); // load the controls we need O2AscxGUI.openAscx(typeof(ascx_Scripts), O2DockState.Document, ascx_ScriptControl); O2AscxGUI.openAscx(typeof(ascx_ScriptsFolder), O2DockState.DockLeft, ascx_ScriptsFolderControl); O2AscxGUI.openAscx(typeof(ascx_AssemblyInvoke), O2DockState.DockRight, ascx_AssemblyInvokeControl); O2AscxGUI.openAscx(typeof(ascx_O2MdbgShell), O2DockState.DockBottom, ascx_O2MdbgShellName); // make sure they are loaded Assert.That(O2AscxGUI.isAscxLoaded(ascx_ScriptControl), "ascxScriptControl was not loaded"); Assert.That(O2AscxGUI.isAscxLoaded(ascx_ScriptsFolderControl), "ascxScriptFolderControl was not loaded"); Assert.That(O2AscxGUI.isAscxLoaded(ascx_AssemblyInvokeControl), "ascx_AssemblyInvokeControl was not loaded"); Assert.That(O2AscxGUI.isAscxLoaded(ascx_O2MdbgShellName), "ascx_AssemblyInvokeControl was not loaded"); // load sample script in scripts folder ascx_ScriptsFolderControl.invokeOnAscx("loadSampleScripts"); var sampleScriptNames = O2AscxGUI.invokeAndGetStringList(ascx_ScriptsFolderControl, "getSampleScriptNames"); Assert.That(sampleScriptNames.Count > 2, "There should be at least 3 scripts"); var targetSampleScript = sampleScriptNames[0]; var targetSampleScriptContents = (string)O2AscxGUI.invokeOnAscxControl(ascx_ScriptsFolderControl, "getSampleScriptContent", new object[] { targetSampleScript }); var scriptFile = (string)O2AscxGUI.invokeOnAscxControl(ascx_ScriptsFolderControl, "createTempScriptFile", new object[] { Path.Combine(DI.config.O2TempDir, targetSampleScript), targetSampleScriptContents }); Assert.IsNotNull(scriptFile, "scriptFile was null"); Assert.That(File.Exists(scriptFile), "scriptFile didn't exist"); O2AscxGUI.invokeOnAscxControl(ascx_ScriptControl, "loadSourceCodeFile", new object[] { scriptFile }); // and confirm that its contents are the same as the content retrieved from the ascx_ScriptsFolderControl var scriptContentsFromAscxScriptsControl = (string)O2AscxGUI.invokeOnAscxControl(ascx_ScriptControl, "getSourceCode"); Assert.IsNotNull(scriptContentsFromAscxScriptsControl, "scriptContentsFromAscxScriptsControl was null"); Assert.That(scriptContentsFromAscxScriptsControl == targetSampleScriptContents, "Source code didn't match"); // let's wait a bit so that the compile event can trigger Processes.Sleep(1000); // the above load should have triggered the auto compile of the source code file, so lets get its type var compiledTypes = O2AscxGUI.invokeAndGetStringList(ascx_AssemblyInvokeControl, "getTypes"); Assert.That(compiledTypes != null && compiledTypes.Count > 0, "prob with types"); // now that we have the type we need to use it to configure the exe settings (since we cant debug a Dll var typeName = compiledTypes[0]; DI.log.info("There were {0} methods compiled", compiledTypes.Count); // final test is to make sure the assembly file to execute exists // first configure the exe compilation mode (which needs the name of the type that holds the Main method O2AscxGUI.invokeOnAscxControl(ascx_ScriptControl, "setExeCompilationMode", new object[] { typeName }); // then simulate a compile by clicking on the compile button O2AscxGUI.clickButton(ascx_ScriptControl, "btSourceCode_Compile"); // let's wait a bit so that the compile event can trigger Processes.Sleep(1000); // now get the compile assembly name which should be an *.exe assemblyToExecute = (string)O2AscxGUI.invokeOnAscxControl(ascx_AssemblyInvokeControl, "getAssemblyLocation"); DI.log.info("The assembly to debug is: {0}", assemblyToExecute); Assert.That(assemblyToExecute != null && File.Exists(assemblyToExecute) && Path.GetExtension(assemblyToExecute) == ".exe", "prob with assemblyToExecute"); // and make sure all supporting dlls are in temp folder (namely O2_Kernel.dll makeSureAllDependentAssembliesExistInTempDirectory(assemblyToExecute); //so that it is null, select a line of the document setSelectedLineNumber(scriptFile, currentSelectedLine); Assert.That(currentSelectedLine == getSelectedLineNumber(), "currentSelectedLine didn't match"); }