/// <summary> /// Initialises the environment /// </summary> /// <returns></returns> static API.Context Initialise() { // Create new context API.Context context = new API.Context(); // Setting core global variables context.SetParameter("console", new API.Console()); context.SetParameter("trifle", new API.Trifle()); context.SetParameter("module", new API.Module()); context.SetParameter("window", new API.Window()); try { // Initialise host env context.RunScript(TrifleJS.Properties.Resources.triflejs_core, "triflejs.core.js"); context.RunScript(TrifleJS.Properties.Resources.triflejs_modules, "triflejs.modules.js"); } catch (Exception ex) { API.Context.Handle(ex); } // Return context return(context); }
/// <summary> /// Initialises the environment /// </summary> /// <returns></returns> static API.Context Initialise() { // Create new context API.Context context = new API.Context(); // Setting core global variables context.SetParameter("console", new API.Console()); context.SetParameter("phantom", new API.Phantom()); context.SetParameter("trifle", new API.Trifle()); context.SetParameter("window", new API.Window()); try { // Initialise host env context.RunScript(Resources.init, "init.js"); context.RunScript(Resources.trifle_Callback, "trifle.Callback.js"); context.RunScript(Resources.trifle_modules_WebPage, "trifle.modules.WebPage.js"); context.RunScript(Resources.trifle_modules_FileSystem, "trifle.modules.FileSystem.js"); context.RunScript(Resources.trifle_modules_System, "trifle.modules.System.js"); } catch (Exception ex) { API.Context.Handle(ex); } // Return context return context; }
/// <summary> /// Initialises the environment /// </summary> /// <returns></returns> static API.Context Initialise() { // Create new context API.Context context = new API.Context(); // Setting core global variables context.SetParameter("console", new API.Console()); context.SetParameter("phantom", new API.Phantom()); context.SetParameter("trifle", new API.Trifle()); context.SetParameter("window", new API.Window()); try { // Initialise host env context.RunScript(Resources.init, "init.js"); context.RunScript(Resources.trifle_Callback, "trifle.Callback.js"); context.RunScript(Resources.trifle_modules_WebPage, "trifle.modules.WebPage.js"); context.RunScript(Resources.trifle_modules_FileSystem, "trifle.modules.FileSystem.js"); context.RunScript(Resources.trifle_modules_System, "trifle.modules.System.js"); } catch (Exception ex) { API.Context.Handle(ex); } // Return context return(context); }
/// <summary> /// Runs unit tests /// </summary> static void UnitTest() { Console.WriteLine(); Console.WriteLine("============================================"); Console.WriteLine("TrifleJS -- Unit Tests"); Console.WriteLine("============================================"); Program.verbose = false; using (Program.context = Initialise()) { try { // Load libs context.RunScript(Resources.test_unit_tools, "test/unit/tools.js"); // Execute Specs context.RunScript(Resources.test_unit_spec_require, "test/unit/spec/require.js"); context.RunScript(Resources.test_unit_spec_webserver, "test/unit/spec/webserver.js"); //context.RunScript(Resources.test_unit_spec_fs, "test/unit/spec/fs.js"); //context.RunScript(Resources.test_unit_spec_webpage, "test/unit/spec/webpage.js"); // Finish context.RunScript(Resources.test_unit_finish, "test/unit/finish.js"); // Keep running until told to stop // This is to make sure asynchronous code gets executed while (true) { Program.DoEvents(); } } catch (Exception ex) { // Handle any exceptions API.Context.Handle(ex); } } }
/// <summary> /// Runs system tests /// </summary> static void Test() { Console.WriteLine(); Console.WriteLine("============================================"); Console.WriteLine("TrifleJS -- System Test"); Console.WriteLine("============================================"); Console.WriteLine(); // Initialize and start console read loop; using (Program.context = Initialise()) { try { // Load libs context.RunScript(Resources.jasmine, "lib/jasmine.js"); context.RunScript(Resources.jasmine_console, "lib/jasmine-console.js"); // Load Spec context.RunScript(Resources.spec_phantom, "spec/phantom.js"); context.RunScript(Resources.spec_webpage, "spec/webpage.js"); // Execute context.RunScript(Resources.run_jasmine, "run-jasmine.js"); // Keep running until told to stop // This is to make sure asynchronous code gets executed while (true) { API.Window.CheckTimers(); } } catch (Exception ex) { // Handle any exceptions API.Context.Handle(ex); } } }
/// <summary> /// Runs compatibility tests /// </summary> static void PhantomTest() { Console.WriteLine(); Console.WriteLine("============================================"); Console.WriteLine("TrifleJS -- Phantom Compatibility Test"); Console.WriteLine("============================================"); Console.WriteLine(); using (Program.context = Initialise()) { try { // Load libs context.RunScript(Resources.test_lib_jasmine, "test/lib/jasmine.js"); context.RunScript(Resources.test_lib_jasmine_console, "test/lib/jasmine-console.js"); context.RunScript(Resources.test_phantom_tools, "test/phantom/tools.js"); // Load Spec context.RunScript(Resources.test_phantom_spec_phantom, "test/phantom/phantom.js"); context.RunScript(Resources.test_phantom_spec_webserver, "test/phantom/webserver.js"); context.RunScript(Resources.test_phantom_spec_webserver, "test/phantom/webpage.js"); // Execute context.RunScript(Resources.test_run_jasmine, "test/phantom/run-jasmine.js"); // Keep running until told to stop // This is to make sure asynchronous code gets executed while (true) { Program.DoEvents(); } } catch (Exception ex) { // Handle any exceptions API.Context.Handle(ex); } } }
/// <summary> /// Runs system tests /// </summary> static void Test() { Console.WriteLine(); Console.WriteLine("============================================"); Console.WriteLine("TrifleJS -- System Test"); Console.WriteLine("============================================"); Console.WriteLine(); // Initialize and start console read loop; using (Program.context = Initialise()) { try { // Load libs context.RunScript(Resources.jasmine, "lib/jasmine.js"); context.RunScript(Resources.jasmine_console, "lib/jasmine-console.js"); // Load Spec context.RunScript(Resources.spec_phantom, "spec/phantom.js"); context.RunScript(Resources.spec_webpage, "spec/webpage.js"); // Execute context.RunScript(Resources.run_jasmine, "run-jasmine.js"); // Keep running until told to stop // This is to make sure asynchronous code gets executed while (true) { API.Window.CheckTimers(); } } catch (Exception ex) { // Handle any exceptions API.Context.Handle(ex); } } }
/// <summary> /// Runs unit tests /// </summary> static void UnitTest() { Console.WriteLine(); Console.WriteLine("============================================"); Console.WriteLine("TrifleJS -- Unit Tests"); Console.WriteLine("============================================"); Program.verbose = false; using (Program.context = Initialise()) { try { // Load libs context.RunScript(Resources.test_unit_tools, "test/unit/tools.js"); // Execute Specs context.RunScript(Resources.test_unit_spec_require, "test/unit/spec/require.js"); context.RunScript(Resources.test_unit_spec_webserver, "test/unit/spec/webserver.js"); //context.RunScript(Resources.test_unit_spec_fs, "test/unit/spec/fs.js"); //context.RunScript(Resources.test_unit_spec_webpage, "test/unit/spec/webpage.js"); // Finish context.RunScript(Resources.test_unit_finish, "test/unit/finish.js"); // Keep running until told to stop // This is to make sure asynchronous code gets executed while (true) { Program.DoEvents(); } } catch (Exception ex) { // Handle any exceptions API.Context.Handle(ex); } } }
/// <summary> /// Runs compatibility tests /// </summary> static void PhantomTest() { Console.WriteLine(); Console.WriteLine("============================================"); Console.WriteLine("TrifleJS -- Phantom Compatibility Test"); Console.WriteLine("============================================"); Console.WriteLine(); using (Program.context = Initialise()) { try { // Load libs context.RunScript(Resources.test_lib_jasmine, "test/lib/jasmine.js"); context.RunScript(Resources.test_lib_jasmine_console, "test/lib/jasmine-console.js"); context.RunScript(Resources.test_phantom_tools, "test/phantom/tools.js"); // Load Spec context.RunScript(Resources.test_phantom_spec_phantom, "test/phantom/phantom.js"); context.RunScript(Resources.test_phantom_spec_webserver, "test/phantom/webserver.js"); context.RunScript(Resources.test_phantom_spec_webserver, "test/phantom/webpage.js"); // Execute context.RunScript(Resources.test_run_jasmine, "test/phantom/run-jasmine.js"); // Keep running until told to stop // This is to make sure asynchronous code gets executed while (true) { Program.DoEvents(); } } catch (Exception ex) { // Handle any exceptions API.Context.Handle(ex); } } }