public void Initialize() { var settingsService = new SettingsService(); ServiceManager.Services.AddService(settingsService); ServiceManager.Services.AddService(new DomainManager()); ServiceManager.Services.AddService(new ProjectService()); ServiceManager.Services.AddService(new AddinRegistry()); ServiceManager.Services.AddService(new AddinManager()); ServiceManager.Services.AddService(new TestAgency()); ServiceManager.Services.InitializeServices(); }
public static int Main(string[] args) { ExtendedConsoleOptions options = new ExtendedConsoleOptions(args); // Create SettingsService early so we know the trace level right at the start SettingsService settingsService = new SettingsService(); InternalTraceLevel level = (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default); if (options.trace != InternalTraceLevel.Default) level = options.trace; InternalTrace.Initialize("nunit-console_%p.log", level); log.Info("NUnit-console.exe starting"); if(!options.nologo) WriteCopyright(); if(options.help) { options.Help(); return ConsoleUi.OK; } if(options.NoArgs) { Console.Error.WriteLine("fatal error: no inputs specified"); options.Help(); return ConsoleUi.OK; } if(!options.Validate()) { foreach( string arg in options.InvalidArguments ) Console.Error.WriteLine("fatal error: invalid argument: {0}", arg ); options.Help(); return ConsoleUi.INVALID_ARG; } // Add Standard Services to ServiceManager ServiceManager.Services.AddService( settingsService ); ServiceManager.Services.AddService( new DomainManager() ); //ServiceManager.Services.AddService( new RecentFilesService() ); ServiceManager.Services.AddService( new ProjectService() ); //ServiceManager.Services.AddService( new TestLoader() ); ServiceManager.Services.AddService( new AddinRegistry() ); ServiceManager.Services.AddService( new AddinManager() ); ServiceManager.Services.AddService( new TestAgency() ); // Initialize Services ServiceManager.Services.InitializeServices(); foreach (string parm in options.Parameters) { if (!Services.ProjectService.CanLoadProject(parm) && !PathUtils.IsAssemblyFileType(parm)) { Console.WriteLine("File type not known: {0}", parm); return ConsoleUi.INVALID_ARG; } } try { ExtendedConsoleUi consoleUi = new ExtendedConsoleUi(); return consoleUi.Execute( options ); } catch( FileNotFoundException ex ) { Console.WriteLine( ex.Message ); return ConsoleUi.FILE_NOT_FOUND; } catch( Exception ex ) { Console.WriteLine( "Unhandled Exception:\n{0}", ex.ToString() ); return ConsoleUi.UNEXPECTED_ERROR; } finally { if(options.wait) { Console.Out.WriteLine("\nHit <enter> key to continue"); Console.ReadLine(); } log.Info( "NUnit-console.exe terminating" ); } }
public static int Main(string[] args) { AgentId = new Guid(args[0]); AgencyUrl = args[1]; #if DEBUG if ( args.Length > 2 && args[2] == "--pause" ) System.Windows.Forms.MessageBox.Show( "Attach debugger if desired, then press OK", "NUnit-Agent"); #endif // Create SettingsService early so we know the trace level right at the start SettingsService settingsService = new SettingsService(false); InternalTrace.Initialize("nunit-agent_%p.log", (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default)); log.Info("Agent process {0} starting", Process.GetCurrentProcess().Id); log.Info("Running under version {0}, {1}", Environment.Version, RuntimeFramework.CurrentFramework.DisplayName); // Add Standard Services to ServiceManager log.Info("Adding Services"); ServiceManager.Services.AddService(settingsService); ServiceManager.Services.AddService(new ProjectService()); ServiceManager.Services.AddService( new DomainManager() ); //ServiceManager.Services.AddService( new RecentFilesService() ); //ServiceManager.Services.AddService( new TestLoader() ); ServiceManager.Services.AddService( new AddinRegistry() ); ServiceManager.Services.AddService( new AddinManager() ); // Initialize Services log.Info("Initializing Services"); ServiceManager.Services.InitializeServices(); Channel = ServerUtilities.GetTcpChannel(); log.Info("Connecting to TestAgency at {0}", AgencyUrl); try { Agency = Activator.GetObject(typeof(TestAgency), AgencyUrl) as TestAgency; } catch (Exception ex) { log.Error("Unable to connect", ex); } if (Channel != null) { log.Info("Starting RemoteTestAgent"); RemoteTestAgent agent = new RemoteTestAgent(AgentId, Agency); try { if (agent.Start()) { log.Debug("Waiting for stopSignal"); agent.WaitForStop(); log.Debug("Stop signal received"); } else log.Error("Failed to start RemoteTestAgent"); } catch (Exception ex) { log.Error("Exception in RemoteTestAgent", ex); } log.Info("Unregistering Channel"); try { ChannelServices.UnregisterChannel(Channel); } catch (Exception ex) { log.Error("ChannelServices.UnregisterChannel threw an exception", ex); } } log.Info("Stopping all services"); ServiceManager.Services.StopAllServices(); log.Info("Agent process {0} exiting", Process.GetCurrentProcess().Id); InternalTrace.Close(); return 0; }
public static NUnitForm nUnitGui_ShowGui(this API_NUnit_Gui nUnitGui, GuiOptions guiOptions) { Func<NUnitForm> createNUnitForm = ()=>{ var sync = new AutoResetEvent(false); NUnitForm nUnitForm = null; O2Thread.staThread( ()=>{ if(NUnit.Util.Services.TestAgency.isNull()) { var nunitGuiRunner = nUnitGui.installer.Executable.parentFolder().pathCombine("lib\\nunit-gui-runner.dll"); nunitGuiRunner.loadAssemblyAndAllItsDependencies(); SettingsService settingsService = new SettingsService(); InternalTrace.Initialize("nunit-gui_%p.log", (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default)); ServiceManager.Services.AddService(settingsService); ServiceManager.Services.AddService(new DomainManager()); ServiceManager.Services.AddService(new RecentFilesService()); ServiceManager.Services.AddService(new ProjectService()); ServiceManager.Services.AddService(new AddinRegistry()); ServiceManager.Services.AddService(new AddinManager()); ServiceManager.Services.AddService(new TestAgency()); ServiceManager.Services.InitializeServices(); } ServiceManager.Services.AddService(new TestLoader(new GuiTestEventDispatcher())); nUnitForm = new NUnitForm(guiOptions); "NUnitForm".o2Cache(nUnitForm); sync.Set(); nUnitForm.ShowDialog(); }); sync.WaitOne(); return nUnitForm; }; return "NUnitForm".o2Cache(createNUnitForm); }
public static int Main(string[] args) { // Create SettingsService early so we know the trace level right at the start SettingsService settingsService = new SettingsService(); InternalTrace.Initialize("nunit-gui_%p.log", (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default)); log.Info("Starting NUnit GUI"); GuiOptions guiOptions = new GuiOptions(args); GuiAttachedConsole attachedConsole = null; if (guiOptions.console) { log.Info("Creating attached console"); attachedConsole = new GuiAttachedConsole(); } if (guiOptions.help) { MessageDisplay.Display(guiOptions.GetHelpText()); return 0; } if (!guiOptions.Validate()) { string message = "Error in command line"; MessageDisplay.Error(message + Environment.NewLine + Environment.NewLine + guiOptions.GetHelpText()); log.Error(message); return 2; } if (guiOptions.cleanup) { log.Info("Performing cleanup of shadow copy cache"); DomainManager.DeleteShadowCopyPath(); return 0; } if (!guiOptions.NoArgs) { if (guiOptions.lang != null) { log.Info("Setting culture to " + guiOptions.lang); Thread.CurrentThread.CurrentUICulture = new CultureInfo(guiOptions.lang); } } try { // Add Standard Services to ServiceManager log.Info("Adding Services"); ServiceManager.Services.AddService(settingsService); ServiceManager.Services.AddService(new DomainManager()); ServiceManager.Services.AddService(new RecentFilesService()); ServiceManager.Services.AddService(new ProjectService()); ServiceManager.Services.AddService(new TestLoader(new GuiTestEventDispatcher())); ServiceManager.Services.AddService(new AddinRegistry()); ServiceManager.Services.AddService(new AddinManager()); ServiceManager.Services.AddService(new TestAgency()); // Initialize Services log.Info("Initializing Services"); ServiceManager.Services.InitializeServices(); } catch (Exception ex) { MessageDisplay.FatalError("Service initialization failed.", ex); log.Error("Service initialization failed", ex); return 2; } // Create container in order to allow ambient properties // to be shared across all top-level forms. log.Info("Initializing AmbientProperties"); AppContainer c = new AppContainer(); AmbientProperties ambient = new AmbientProperties(); c.Services.AddService(typeof(AmbientProperties), ambient); log.Info("Constructing Form"); NUnitForm form = new NUnitForm(guiOptions); c.Add(form); try { log.Info("Starting Gui Application"); Application.Run(form); log.Info("Application Exit"); } catch( Exception ex ) { log.Error("Gui Application threw an excepion", ex ); throw; } finally { log.Info("Stopping Services"); ServiceManager.Services.StopAllServices(); } if (attachedConsole != null) { Console.WriteLine("Press Enter to exit"); Console.ReadLine(); attachedConsole.Close(); } log.Info("Exiting NUnit GUI"); InternalTrace.Close(); return 0; }
public static new int Main(string[] args) { CommandOptionsArxNet options = new CommandOptionsArxNet(args); // Create SettingsService early so we know the trace level right at the start SettingsService settingsService = new SettingsService(); InternalTraceLevel level = (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default); if (options.trace != InternalTraceLevel.Default) level = options.trace; InternalTrace.Initialize("nunit-command-arxnet_%p.log", level); log.Info("NUnit-command-arxnet.dll starting"); if (!options.nologo) WriteCopyright(); if (options.help) { options.Help(); return CommandUiArxNet.OK; } Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; if (options.cleanup) { log.Info("Performing cleanup of shadow copy cache"); DomainManager.DeleteShadowCopyPath(); ed.WriteMessage("\nShadow copy cache emptied"); return CommandUiArxNet.OK; } if (options.NoArgs) { ed.WriteMessage("\nfatal error: no inputs specified"); options.Help(); return CommandUiArxNet.OK; } if (!options.Validate()) { foreach (string arg in options.InvalidArguments) ed.WriteMessage("\nfatal error: invalid argument: {0}", arg); options.Help(); return CommandUiArxNet.INVALID_ARG; } // Add Standard Services to ServiceManager ServiceManager.Services.AddService(new SettingsService()); ServiceManager.Services.AddService(new DomainManager()); //ServiceManager.Services.AddService( new RecentFilesService() ); ServiceManager.Services.AddService(new ProjectService()); //ServiceManager.Services.AddService( new TestLoader() ); ServiceManager.Services.AddService(new AddinRegistry()); ServiceManager.Services.AddService(new AddinManager()); // Hack: Resolves conflict with gui testagency when running // console tests under the gui. if (!AppDomain.CurrentDomain.FriendlyName.StartsWith("test-domain-")) ServiceManager.Services.AddService(new TestAgency()); // Initialize Services ServiceManager.Services.InitializeServices(); foreach (string parm in options.Parameters) { if (!Services.ProjectService.CanLoadProject(parm) && !PathUtils.IsAssemblyFileType(parm)) { ed.WriteMessage("\nFile type not known: {0}", parm); return CommandUiArxNet.INVALID_ARG; } } try { CommandUiArxNet commandUiArxNet = new CommandUiArxNet(); return commandUiArxNet.Execute(options); } catch (FileNotFoundException ex) { ed.WriteMessage("\n" + ex.Message); return CommandUiArxNet.FILE_NOT_FOUND; } catch (Autodesk.AutoCAD.Runtime.Exception ex) { ed.WriteMessage("\nAutoCAD Exception:\n{0}", ex.ToString()); return CommandUiArxNet.UNEXPECTED_ERROR; } catch (System.Exception ex) { ed.WriteMessage("\nUnhandled Exception:\n{0}", ex.ToString()); return CommandUiArxNet.UNEXPECTED_ERROR; } finally { if (options.wait) { ed.GetString(new PromptStringOptions("\n\nHit <enter> key to continue")); } log.Info("NUnit-command-arxnet.dll terminating"); } }