-
Notifications
You must be signed in to change notification settings - Fork 16
/
Write and Execute Unit Tests.h2
51 lines (43 loc) · 1.57 KB
/
Write and Execute Unit Tests.h2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
O2ConfigSettings.O2Version = "WriteUnitTest";
O2Setup.extractEmbededConfigZips();
//var topPanel = panel.add_Panel(true);
var topPanel = O2Gui.open<Panel>("Write and Execute Unit Tests", 1000,600);
var codeEditor = topPanel.add_SourceCodeEditor();
var unitTest = codeEditor.insert_Right<ascx_XRules_UnitTests>(350);
unitTest.control<CheckBox>(true).@check();
unitTest.insert_Below<Panel>(130).add_LogViewer();
Action<string> loadFileAndCompile =
(file)=>{
codeEditor.open(file);
codeEditor.compileSourceCode();
};
TextBox textBox_LoadFile = null;
Button button_LoadFile = null;
topPanel.insert_Above<Panel>(25).add_LabelAndTextAndButton("Unit Test file","","load", ref textBox_LoadFile, ref button_LoadFile, loadFileAndCompile);
Action<string> loadFile =
(file)=>{
textBox_LoadFile.set_Text(file);
loadFileAndCompile(file);
};
textBox_LoadFile.onDrop((text)=> loadFile(text));
codeEditor.onCompile(
(assembly)=>{
unitTest.loadFile(assembly.Location,true);
if(unitTest.control<CheckBox>(true).@checked())
unitTest.invoke("executeAllLoadedTests");
unitTest.XRulesTreeView_ExpandAll();
});
//
//Default data
var tempFile = "DefaultUnitTest.cs".local().fileContents().saveWithExtension(".cs");
textBox_LoadFile.set_Text(tempFile);
loadFile(tempFile);
//button_LoadFile.click();
return loadFile;
//using O2.XRules.Database.APIs
//using O2.Core.XRules.Ascx
//O2Ref:O2_Core_XRules.dll
//O2Ref:O2_External_O2Mono.dll
//O2Ref:nunit.framework.dll
//O2File:_Extra_methods_To_Add_to_Main_CodeBase.cs
//O2Package:DefaultUnitTest.cs