using System; using System.Collections; using System.Reflection; using NTime.Framework; using NTime.GUI; namespace NTime.NTimeConsole { /// <summary> /// This class is main NTime console application. /// </summary> class NTimeMainConsole { /// <summary> /// List of loaded assemblies read from command line. /// </summary> public ArrayList assemblies = new ArrayList(); /// <summary> /// Project filename read from command line. /// </summary> public string ProjectFile; /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { NTimeMainConsole mc = new NTimeMainConsole(); if(mc.ParseCmdline(args) == false) { Help(); return; } Assembly executingAssembly = Assembly.GetExecutingAssembly(); Version version = executingAssembly.GetName().Version; Console.WriteLine("NTime Console (version " + version.ToString(3) + ")"); Console.WriteLine("Copyright (c) 2004 By Adam Slosarski"); Console.WriteLine("Running tests..."); Console.WriteLine(""); NTimeForm f = new NTimeForm(); if(mc.ProjectFile != "") { f.ntimeMain.ProjectName = mc.ProjectFile; f.ntimeMain.LoadProject(); } else { foreach(string s in mc.assemblies) { f.ntimeMain.AssemblyNames.Add(s); } f.ntimeMain.Reload(); } f.ntimeMain.Run(); f.TimerQuery.Enabled = false; int actual = 0, blinker = 0; do { f.ntimeMain.QueryTests(); if((blinker & 3) == 0) Console.Write("\\"); else if((blinker & 3) == 1) Console.Write("|"); else if((blinker & 3) == 2) Console.Write("/"); else if((blinker & 3) == 3) Console.Write("-"); blinker++; // this sleep must occur, otherwise performance counters and other // tests will produce wrong timings. System.Threading.Thread.Sleep(1000); lock(f.ntimeMain.rl) { Console.Write("\b"); for(;actual < f.ntimeMain.rl.CompletedIndex; actual++) { foreach(string s in ((TestUnit)f.ntimeMain.rl.CompletedTests[actual]).UnitResultInfo) { System.Console.WriteLine(s); } } } } while(f.ntimeMain.Running == true); Console.WriteLine(""); Console.WriteLine("Tests finished"); Console.WriteLine("=============="); Console.WriteLine("Total: " + f.ntimeMain.totalTests); Console.WriteLine("Time: " + f.ntimeMain.totalTestsTime.ToString()); Console.WriteLine("Accepted: " + f.ntimeMain.acceptedTests); Console.WriteLine("Rejected: " + f.ntimeMain.rejectedTests); } /// <summary> /// Parses command line arguments to run console application properly. /// </summary> /// <param name="args">Arguments forwarded from console main entry point.</param> /// <returns>Return true when arguments are correct, otherwise false.</returns> public bool ParseCmdline(string[] args) { #region Commandline check if(args.Length > 0) { for(int i = 0; i < args.Length; i++) { if(System.IO.Path.GetExtension(args[i]) == ".ntime") ProjectFile = args[i]; else if(System.IO.Path.GetExtension(args[i]) == ".dll" || System.IO.Path.GetExtension(args[i]) == ".exe") assemblies.Add(args[i]); } } else return false; return true; #endregion } /// <summary> /// Prints program usage and command line syntax. /// </summary> public static void Help() { #region Usage command line Console.WriteLine("NTime Console"); Console.WriteLine("Copyright (c) 2004 By Adam Slosarski"); Console.WriteLine("Syntax: NTime.exe [assemblies or project file]"); #endregion } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.