public static int Main(string[] args) { var options = new CommandLineOptions(args); if (options.ShowHelp) { // TODO: We would need to have a custom message box // in order to use a fixed font and display the options // so that the values all line up. MessageDisplay.Info(options.GetHelpText()); return(0); } if (!options.Validate()) { var NL = Environment.NewLine; var sb = new StringBuilder($"Error(s) in command line:{NL}"); foreach (string msg in options.ErrorMessages) { sb.Append($" {msg}{NL}"); } sb.Append($"{NL}{options.GetHelpText()}"); MessageDisplay.Error(sb.ToString()); return(2); } // Currently the InternalTraceLevel can only be set from the command-line. // We can't use user settings to provide a default because the settings // are an engine service and the engine have the internal trace level // set as part of its initialization. var traceLevel = options.InternalTraceLevel; // This initializes the trace setting for the GUI itself. InternalTrace.Initialize($"InternalTrace.{Process.GetCurrentProcess().Id}.gui.log", traceLevel); log.Info($"Starting TestCentric Runner - InternalTraceLevel = {traceLevel}"); // 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("Creating TestEngine"); ITestEngine testEngine = TestEngineActivator.CreateInstance(); testEngine.InternalTraceLevel = traceLevel; log.Info("Instantiating TestModel"); ITestModel model = new TestModel(testEngine); log.Info("Constructing Form"); TestCentricMainForm form = new TestCentricMainForm(model, options); 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("Exiting TestCentric Runner"); InternalTrace.Close(); testEngine.Dispose(); } return(0); }
public static int Main(string[] args) { var options = new CommandLineOptions(args); if (options.ShowHelp) { // TODO: We would need to have a custom message box // in order to use a fixed font and display the options // so that the values all line up. MessageDisplay.Info(GetHelpText(options)); return(0); } if (!options.Validate()) { var NL = Environment.NewLine; var sb = new StringBuilder($"Error(s) in command line:{NL}"); foreach (string msg in options.ErrorMessages) { sb.Append($" {msg}{NL}"); } sb.Append($"{NL}{GetHelpText(options)}"); MessageDisplay.Error(sb.ToString()); return(2); } // Currently the InternalTraceLevel can only be set from the command-line. // We can't use user settings to provide a default because the settings // are an engine service and the engine have the internal trace level // set as part of its initialization. var traceLevel = options.InternalTraceLevel != null ? (InternalTraceLevel)Enum.Parse(typeof(InternalTraceLevel), options.InternalTraceLevel) : InternalTraceLevel.Off; // This initializes the trace setting for the GUI itself. InternalTrace.Initialize($"InternalTrace.{Process.GetCurrentProcess().Id}.gui.log", traceLevel); log.Info($"Starting TestCentric Runner - InternalTraceLevel = {traceLevel}"); log.Info("Creating TestEngine"); ITestEngine testEngine = TestEngineActivator.CreateInstance(); testEngine.InternalTraceLevel = traceLevel; log.Info("Instantiating TestModel"); ITestModel model = new TestModel(testEngine, "TestCentric"); model.PackageOverrides.Add(EnginePackageSettings.InternalTraceLevel, traceLevel.ToString()); if (options.ProcessModel != null) { model.PackageOverrides.Add(EnginePackageSettings.ProcessModel, options.ProcessModel); } if (options.DomainUsage != null) { model.PackageOverrides.Add(EnginePackageSettings.DomainUsage, options.DomainUsage); } if (options.MaxAgents >= 0) { model.PackageOverrides.Add(EnginePackageSettings.MaxAgents, options.MaxAgents); } if (options.RunAsX86) { model.PackageOverrides.Add(EnginePackageSettings.RunAsX86, true); } log.Info("Constructing Form"); TestCentricMainView view = new TestCentricMainView(); log.Info("Constructing presenters"); new ProgressBarPresenter(view.ProgressBarView, model); new StatusBarPresenter(view.StatusBarView, model); new ErrorsAndFailuresPresenter(view.ErrorsAndFailuresView, model); new TestsNotRunPresenter(view.TestsNotRunView, model); new TextOutputPresenter(view.TextOutputView, model); new TreeViewPresenter(view.TreeView, model); new CategoryPresenter(view.CategoryView, model); new TestCentricPresenter(view, model, options); try { log.Info("Starting Gui Application"); Application.Run(view); log.Info("Application Exit"); } catch (Exception ex) { log.Error("Gui Application threw an exception", ex); throw; } finally { log.Info("Exiting TestCentric Runner"); InternalTrace.Close(); testEngine.Dispose(); } return(0); }
public static int Main(string[] args) { var options = new CommandLineOptions(args); if (options.ShowHelp) { // TODO: We would need to have a custom message box // in order to use a fixed font and display the options // so that the values all line up. MessageDisplay.Info(GetHelpText(options)); return(0); } if (!options.Validate()) { var NL = Environment.NewLine; var sb = new StringBuilder($"Error(s) in command line:{NL}"); foreach (string msg in options.ErrorMessages) { sb.Append($" {msg}{NL}"); } sb.Append($"{NL}{GetHelpText(options)}"); MessageDisplay.Error(sb.ToString()); return(2); } ITestEngine engine = TestEngineActivator.CreateInstance(); log.Info("Instantiating TestModel"); ITestModel model = TestModel.CreateTestModel(engine, options); log.Info("Constructing Form"); TestCentricMainView view = new TestCentricMainView(); log.Info("Constructing presenters"); new ProgressBarPresenter(view.ProgressBarView, model); new StatusBarPresenter(view.StatusBarView, model); new ErrorsAndFailuresPresenter(view.ErrorsAndFailuresView, model); new TestsNotRunPresenter(view.TestsNotRunView, model); new TextOutputPresenter(view.TextOutputView, model); new TreeViewPresenter(view.TreeView, model); new CategoryPresenter(view.CategoryView, model); new TestCentricPresenter(view, model, options); try { log.Info("Starting Gui Application"); Application.Run(view); log.Info("Application Exit"); } catch (Exception ex) { log.Error("Gui Application threw an exception", ex); throw; } finally { log.Info("Exiting TestCentric Runner"); InternalTrace.Close(); model.Dispose(); } return(0); }