Esempio n. 1
0
        // Our nunit project watcher
        //private FileWatcher projectWatcher;

        #endregion

        #region Constructor

        // TODO: Use an interface for view and model
        public TestCentricPresenter(TestCentricMainForm form, ITestModel model, CommandLineOptions options)
        {
            Form    = form;
            Model   = model;
            Options = options;

            UserSettings = Model.Services.UserSettings;
            RecentFiles  = Model.Services.RecentFiles;
        }
Esempio n. 2
0
        private void OnRecentFileClick(object sender, EventArgs e)
        {
            MenuItem item         = (MenuItem)sender;
            string   testFileName = item.Text.Substring(2);

            // TODO: Figure out a better way
            TestCentricMainForm form = item.GetMainMenu().GetForm() as TestCentricMainForm;

            if (form != null)
            {
                form.Presenter.LoadTests(testFileName);
            }
        }
Esempio n. 3
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(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);
        }