コード例 #1
0
        private static void ShowHelpText(GuiOptions options)
        {
            StringWriter writer = new StringWriter();

            writer.WriteLine("NUNIT [inputfiles] [options]");
            writer.WriteLine();
            writer.WriteLine("Loads and optionally runs a set of NUnit tests using the GUI runner.");
            writer.WriteLine();
            writer.WriteLine("InputFiles:");
            writer.WriteLine("   One or more assemblies or test projects of a recognized type.");
            writer.WriteLine();
            writer.WriteLine("Options:");
            options.WriteOptionDescriptions(writer);
            writer.WriteLine();
            writer.WriteLine("Description:");
            writer.WriteLine("   By default, this command loads the tests contained in the input");
            writer.WriteLine("   specified, displaying them in the GUI runner, where the user may");
            writer.WriteLine("   run some or all of them as desired. If no input files are given");
            writer.WriteLine("   the tests contained in the most recently used project or assembly");
            writer.WriteLine("   are loaded, unless the --noload option is specified.");
            writer.WriteLine();
            writer.WriteLine("   CATEGORIES may be specified singly, as a comma-separated list or");
            writer.WriteLine("   as a category expression.");
            writer.WriteLine();
            writer.WriteLine("   Trace LEVEL may be Off, Error, Warning, Info, Verbose or Debug.");

            MessageBox.Show(writer.GetStringBuilder().ToString(), "NUnit - Help");
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            GuiOptions options = new GuiOptions();

            try
            {
                options.Parse(args);
            }
            catch (OptionException ex)
            {
                string msg = string.Format("{0} {1}", ex.Message, ex.OptionName);
                MessageBox.Show(msg, "NUnit - OptionException", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (options.ShowHelp)
            {
                ShowHelpText(options);
                return;
            }

            var testEngine = TestEngineActivator.CreateInstance();

            if (options.InternalTraceLevel != null)
            {
                testEngine.InternalTraceLevel = (InternalTraceLevel)Enum.Parse(typeof(InternalTraceLevel), options.InternalTraceLevel);
            }

            var model = new TestModel(testEngine);

            var form = new MainForm();

            new MainPresenter(form, model, options);
            new ProgressBarPresenter(form.ProgressBarView, model);
            new TreeViewPresenter(form.TestTreeView, model);
            new StatusBarPresenter(form.StatusBarView, model);
            new TestPropertiesPresenter(form.PropertiesView, model);

            //new RecentFiles(settingsServiceServiceService._settings);
            //new RecentFilesPresenter(form, settingsServiceServiceService);

            try
            {
                Application.Run(form);
            }
            finally
            {
                testEngine.Dispose();
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: KGuetter/nunit-gui
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            GuiOptions options = new GuiOptions();
            try
            {
                options.Parse(args);
            }
            catch (OptionException ex)
            {
                string msg = string.Format("{0} {1}", ex.Message, ex.OptionName);
                MessageBox.Show(msg, "NUnit - OptionException", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (options.ShowHelp)
            {
                ShowHelpText(options);
                return;
            }

            var testEngine = TestEngineActivator.CreateInstance();
            if (options.InternalTraceLevel != null)
                testEngine.InternalTraceLevel = (InternalTraceLevel)Enum.Parse(typeof(InternalTraceLevel), options.InternalTraceLevel);

            var model = new TestModel(testEngine);

            var form = new MainForm();
            new MainPresenter(form, model, options);
            new ProgressBarPresenter(form.ProgressBarView, model);
            new TreeViewPresenter(form.TestTreeView, model);
            new StatusBarPresenter(form.StatusBarView, model);
            new TestPropertiesPresenter(form.PropertiesView, model);

            //new RecentFiles(settingsServiceServiceService._settings);
            //new RecentFilesPresenter(form, settingsServiceServiceService);

            try
            {
                Application.Run(form);
            }
            finally
            {
                testEngine.Dispose();
            }
        }
コード例 #4
0
        static int Main(string[] args)
        {
            NUnitForm.CommandLineOptions command =
                new NUnitForm.CommandLineOptions();

            GuiOptions parser = new GuiOptions(args);

            if (parser.Validate() && !parser.help)
            {
                if (!parser.NoArgs)
                {
                    if (parser.IsAssembly)
                    {
                        command.testFileName = parser.Assembly;
                    }
                    command.configName = parser.config;
                    command.testName   = parser.fixture;
                    command.noload     = parser.noload;
                    command.autorun    = parser.run;
                }

                if (command.testFileName != null)
                {
                    FileInfo fileInfo = new FileInfo(command.testFileName);
                    if (!fileInfo.Exists)
                    {
                        string message = String.Format("{0} does not exist", fileInfo.FullName);
                        UserMessage.DisplayFailure(message, "Specified test file does not exist");
                        return(1);
                    }
                    else
                    {
                        command.testFileName = fileInfo.FullName;
                    }
                }

                NUnitForm form = new NUnitForm(command);
                Application.Run(form);
            }
            else
            {
                string message = parser.GetHelpText();
                UserMessage.DisplayFailure(message, "Help Syntax");
                return(2);
            }

            return(0);
        }
コード例 #5
0
        public static int Main(string[] args)
        {
            NUnitForm.CommandLineOptions command =
                new NUnitForm.CommandLineOptions();

            GuiOptions parser = new GuiOptions(args);

            if (parser.Validate() && !parser.help)
            {
                if (parser.cleanup)
                {
                    DomainManager.DeleteShadowCopyPath();
                    return(0);
                }

                if (!parser.NoArgs)
                {
                    if (parser.IsAssembly)
                    {
                        command.testFileName = parser.Assembly;
                    }
                    command.configName = parser.config;
                    command.testName   = parser.fixture;
                    command.noload     = parser.noload;
                    command.autorun    = parser.run;
                    if (parser.lang != null)
                    {
                        Thread.CurrentThread.CurrentUICulture =
                            new CultureInfo(parser.lang);
                    }

                    if (parser.HasInclude)
                    {
                        command.categories = parser.include;
                        command.exclude    = false;
                    }
                    else if (parser.HasExclude)
                    {
                        command.categories = parser.exclude;
                        command.exclude    = true;
                    }
                }

                // Add Standard Services to ServiceManager
                ServiceManager.Services.AddService(new SettingsService());
                ServiceManager.Services.AddService(new DomainManager());
                ServiceManager.Services.AddService(new RecentFilesService());
                ServiceManager.Services.AddService(new TestLoader(new GuiTestEventDispatcher()));
                ServiceManager.Services.AddService(new AddinRegistry());
                ServiceManager.Services.AddService(new AddinManager());

                // Initialize Services
                ServiceManager.Services.InitializeServices();

                // Create container in order to allow ambient properties
                // to be shared across all top-level forms.
                AppContainer      c       = new AppContainer();
                AmbientProperties ambient = new AmbientProperties();
                c.Services.AddService(typeof(AmbientProperties), ambient);
                NUnitForm form = new NUnitForm(command);
                c.Add(form);

                try
                {
                    Application.Run(form);
                }
                finally
                {
                    ServiceManager.Services.StopAllServices();
                }
            }
            else
            {
                string message = parser.GetHelpText();
                UserMessage.DisplayFailure(message, "Help Syntax");
                return(2);
            }

            return(0);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: KGuetter/nunit-gui
        private static void ShowHelpText(GuiOptions options)
        {
            StringWriter writer = new StringWriter();

            writer.WriteLine("NUNIT [inputfiles] [options]");
            writer.WriteLine();
            writer.WriteLine("Loads and optionally runs a set of NUnit tests using the GUI runner.");
            writer.WriteLine();
            writer.WriteLine("InputFiles:");
            writer.WriteLine("   One or more assemblies or test projects of a recognized type.");
            writer.WriteLine();
            writer.WriteLine("Options:");
            options.WriteOptionDescriptions(writer);
            writer.WriteLine();
            writer.WriteLine("Description:");
            writer.WriteLine("   By default, this command loads the tests contained in the input");
            writer.WriteLine("   specified, displaying them in the GUI runner, where the user may");
            writer.WriteLine("   run some or all of them as desired. If no input files are given");
            writer.WriteLine("   the tests contained in the most recently used project or assembly");
            writer.WriteLine("   are loaded, unless the --noload option is specified.");
            writer.WriteLine();
            writer.WriteLine("   CATEGORIES may be specified singly, as a comma-separated list or");
            writer.WriteLine("   as a category expression.");
            writer.WriteLine();
            writer.WriteLine("   Trace LEVEL may be Off, Error, Warning, Info, Verbose or Debug.");

            MessageBox.Show(writer.GetStringBuilder().ToString(), "NUnit - Help");
        }
コード例 #7
0
ファイル: AppEntry.cs プロジェクト: wsgan001/asegrp
        public static int Main(string[] args)
        {
            NTrace.Info("Starting NUnit GUI");

            GuiOptions guiOptions = new GuiOptions(args);

            GuiAttachedConsole attachedConsole = null;

            if (guiOptions.console)
            {
                attachedConsole = new GuiAttachedConsole();
            }

            if (!guiOptions.Validate() || guiOptions.help)
            {
                string message = guiOptions.GetHelpText();
                UserMessage.DisplayFailure(message, "Help Syntax");
                return(2);
            }

            if (guiOptions.cleanup)
            {
                DomainManager.DeleteShadowCopyPath();
                return(0);
            }

            if (!guiOptions.NoArgs)
            {
                if (guiOptions.lang != null)
                {
                    Thread.CurrentThread.CurrentUICulture =
                        new CultureInfo(guiOptions.lang);
                }
            }

            // Add Standard Services to ServiceManager
            ServiceManager.Services.AddService(new SettingsService());
            ServiceManager.Services.AddService(new DomainManager());
            ServiceManager.Services.AddService(new RecentFilesService());
            ServiceManager.Services.AddService(new TestLoader(new GuiTestEventDispatcher()));
            ServiceManager.Services.AddService(new AddinRegistry());
            ServiceManager.Services.AddService(new AddinManager());
            ServiceManager.Services.AddService(new TestAgency());

            // Initialize Services
            ServiceManager.Services.InitializeServices();

            // Create container in order to allow ambient properties
            // to be shared across all top-level forms.
            AppContainer      c       = new AppContainer();
            AmbientProperties ambient = new AmbientProperties();

            c.Services.AddService(typeof(AmbientProperties), ambient);
            NUnitForm form = new NUnitForm(guiOptions);

            c.Add(form);

            try
            {
                Application.Run(form);
            }
            finally
            {
                ServiceManager.Services.StopAllServices();
            }

            if (attachedConsole != null)
            {
                Console.WriteLine("Press Enter to exit");
                Console.ReadLine();
                attachedConsole.Close();
            }

            NTrace.Info("Exiting NUnit GUI");

            return(0);
        }
コード例 #8
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);
        }