Exemplo n.º 1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                InitializeTraceLevel();

                AppContainer container = new AppContainer();
                MainForm     form      = new MainForm();
                container.Add(form);

                logger.Info(Resources.StartingCodeBuilder);
                Application.Run(form);
                logger.Info(Resources.CodeBuilderExit);
            }
            catch (Exception ex)
            {
                logger.Error(Resources.Startup, ex);
                MessageBoxHelper.DisplayFailure(ex.Message);
            }

            InternalTrace.Close();
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public static int Main(string[] args)
        {
            AgentId   = new Guid(args[0]);
            AgencyUrl = args[1];

            InternalTrace.Initialize("nunit-agent_%p.log");
            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(new SettingsService(false));
            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);
        }
Exemplo n.º 4
0
        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);
        }