3 using System.Reflection;
\r
8 namespace NUnit.ConsoleRunner
\r
11 /// Summary description for Runner.
\r
16 public static int Main(string[] args)
\r
18 NTrace.Info( "NUnit-console.exe starting" );
\r
20 ConsoleOptions options = new ConsoleOptions(args);
\r
28 return ConsoleUi.OK;
\r
33 Console.Error.WriteLine("fatal error: no inputs specified");
\r
35 return ConsoleUi.OK;
\r
38 if(!options.Validate())
\r
40 foreach( string arg in options.InvalidArguments )
\r
41 Console.Error.WriteLine("fatal error: invalid argument: {0}", arg );
\r
43 return ConsoleUi.INVALID_ARG;
\r
46 // Add Standard Services to ServiceManager
\r
47 ServiceManager.Services.AddService( new SettingsService() );
\r
48 ServiceManager.Services.AddService( new DomainManager() );
\r
49 //ServiceManager.Services.AddService( new RecentFilesService() );
\r
50 //ServiceManager.Services.AddService( new TestLoader() );
\r
51 ServiceManager.Services.AddService( new AddinRegistry() );
\r
52 ServiceManager.Services.AddService( new AddinManager() );
\r
53 // TODO: Resolve conflict with gui testagency when running
\r
54 // console tests under the gui.
\r
55 //ServiceManager.Services.AddService( new TestAgency() );
\r
57 // Initialize Services
\r
58 ServiceManager.Services.InitializeServices();
\r
62 ConsoleUi consoleUi = new ConsoleUi();
\r
63 return consoleUi.Execute( options );
\r
65 catch( FileNotFoundException ex )
\r
67 Console.WriteLine( ex.Message );
\r
68 return ConsoleUi.FILE_NOT_FOUND;
\r
70 catch( Exception ex )
\r
72 Console.WriteLine( "Unhandled Exception:\n{0}", ex.ToString() );
\r
73 return ConsoleUi.UNEXPECTED_ERROR;
\r
79 Console.Out.WriteLine("\nHit <enter> key to continue");
\r
83 NTrace.Info( "NUnit-console.exe terminating" );
\r
88 private static void WriteCopyright()
\r
90 Assembly executingAssembly = Assembly.GetExecutingAssembly();
\r
91 System.Version version = executingAssembly.GetName().Version;
\r
93 string productName = "NUnit";
\r
94 string copyrightText = "Copyright (C) 2002-2007 Charlie Poole.\r\nCopyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.\r\nCopyright (C) 2000-2002 Philip Craig.\r\nAll Rights Reserved.";
\r
96 object[] objectAttrs = executingAssembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false);
\r
97 if ( objectAttrs.Length > 0 )
\r
98 productName = ((AssemblyProductAttribute)objectAttrs[0]).Product;
\r
100 objectAttrs = executingAssembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
\r
101 if ( objectAttrs.Length > 0 )
\r
102 copyrightText = ((AssemblyCopyrightAttribute)objectAttrs[0]).Copyright;
\r
104 Console.WriteLine(String.Format("{0} version {1}", productName, version.ToString(3)));
\r
105 Console.WriteLine(copyrightText);
\r
106 Console.WriteLine();
\r
108 Console.WriteLine( "Runtime Environment - " );
\r
109 RuntimeFramework framework = RuntimeFramework.CurrentFramework;
\r
110 Console.WriteLine( string.Format(" OS Version: {0}", Environment.OSVersion ) );
\r
111 Console.WriteLine( string.Format(" CLR Version: {0} ( {1} )",
\r
112 Environment.Version, framework.GetDisplayName() ) );
\r
114 Console.WriteLine();
\r