Ejemplo n.º 1
0
 public CommandLineExecutionEngine(ILogger logger, ArgOptions args)
     : this(logger, args,
            new StatLightConfigurationFactory(logger),
            runner => runner.Run(),
            new StatLightRunnerFactory(logger))
 {
 }
Ejemplo n.º 2
0
 internal CommandLineExecutionEngine(ILogger logger, ArgOptions args, IStatLightConfigurationFactory statLightConfigurationFactory, Func <IRunner, TestReport> runnerFunc, IStatLightRunnerFactory statLightRunnerFactory)
 {
     _logger = logger;
     _statLightRunnerFactory = statLightRunnerFactory;
     _options = args;
     _statLightConfigurationFactory = statLightConfigurationFactory;
     _runnerFunc = runnerFunc;
 }
Ejemplo n.º 3
0
 private static void WriteErrorToConsole(string errorMessage, string beginMsg)
 {
     Write("");
     Write("");
     ArgOptions.ShowHelpMessage(Console.Out);
     Write("");
     Write("************* " + beginMsg + " *************");
     errorMessage.WrapConsoleMessageWithColor(Settings.Default.ConsoleColorError, true);
     Write("*********************************");
 }
Ejemplo n.º 4
0
        public static void ShowHelpMessage(TextWriter @out, ArgOptions options)
        {
            ShowHelpMessage(@out);

            /*
             * DEBUG - maybe some work and could add value (for when a user inputs bad data - display to them what statlight "sees")
             */

            //@out.WriteLine("---------- options ----------");
            //@out.WriteLine("--- Continuous             - {0}".FormatWith(options.ContinuousIntegrationMode));
            //@out.WriteLine("--- XapPath                - '{0}'".FormatWith(options.XapPath));
            //@out.WriteLine("--- TagFilters             - '{0}'".FormatWith(options.TagFilters));
            //@out.WriteLine("--- ShowTestingBrowserHost - {0}".FormatWith(options.ShowTestingBrowserHost));
            //@out.WriteLine("--- TestProvider           - {0}".FormatWith(options.UnitTestProviderType));
            //@out.WriteLine("--- ReportOutputFile       - '{0}'".FormatWith(options.XmlReportOutputPath));
            //@out.WriteLine("--- teamcity               - {0}".FormatWith(options.OutputForTeamCity));
            //@out.WriteLine("--- webserveronly          - {0}".FormatWith(options.StartWebServerOnly));
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                Console.WriteLine(e.ExceptionObject);
            };
            PrintNameVersionAndCopyright();

            ArgOptions options;

            using (var consoleIconSwapper = new ConsoleIconSwapper())
            {
                consoleIconSwapper.ShowConsoleIcon(CoreResources.FavIcon);

                try
                {
                    options = new ArgOptions(args);

                    if (options.ShowHelp)
                    {
                        ArgOptions.ShowHelpMessage(Console.Out, options);
                        return;
                    }

                    if (!options.XapPaths.Any() && !options.Dlls.Any())
                    {
                        throw new StatLightException("No xap or silverlight dll's specified.");
                    }

                    ILogger logger = GetLogger(options.IsRequestingDebug);

                    var commandLineExecutionEngine   = new CommandLineExecutionEngine(logger, options);
                    TestReportCollection testReports = commandLineExecutionEngine.Run();

                    if (testReports.FinalResult == RunCompletedState.Failure)
                    {
                        Environment.ExitCode = ExitFailed;
                    }
                    else
                    {
                        Environment.ExitCode = ExitSucceeded;
                    }
                }
                catch (AddressAccessDeniedException addressAccessDeniedException)
                {
                    Environment.ExitCode = ExitFailed;
                    var helpMessage = @"
Cannot run StatLight. The current account does not have the correct privilages.

Exception:
{0}

Try: (the following two steps that should allow StatLight to start a web server on the requested port)
     1. Run cmd.exe as Administrator.
     2. Enter the following command in the command prompt.
          netsh http add urlacl url=http://+:8887/ user=DOMAIN\user
".FormatWith(addressAccessDeniedException.Message);

                    WriteErrorToConsole(helpMessage, "Error");
                }
                catch (FileNotFoundException fileNotFoundException)
                {
                    HandleKnownError(fileNotFoundException);
                }
                catch (StatLightException statLightException)
                {
                    HandleKnownError(statLightException);
                }

                catch (Exception exception)
                {
                    HandleUnknownError(exception);
                }
            }
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                Console.WriteLine(e.ExceptionObject);
            };

            PrintNameVersionAndCopyright();

            using (var consoleIconSwapper = new ConsoleIconSwapper())
            {
                consoleIconSwapper.ShowConsoleIcon(CoreResources.FavIcon);

                try
                {
                    var options = new ArgOptions(args);

                    if (options.ShowHelp)
                    {
                        ArgOptions.ShowHelpMessage(Console.Out, options);
                        return;
                    }

                    if (!options.XapPaths.Any() && !options.Dlls.Any())
                    {
                        throw new StatLightException("No xap or silverlight dll's specified.");
                    }

                    var inputOptions = new InputOptions()
                                       .SetWindowGeometry(options.WindowGeometry)
                                       .SetUseRemoteTestPage(options.UseRemoteTestPage)
                                       .SetMethodsToTest(options.MethodsToTest)
                                       .SetMicrosoftTestingFrameworkVersion(options.MicrosoftTestingFrameworkVersion)
                                       .SetTagFilters(options.TagFilters)
                                       .SetUnitTestProviderType(options.UnitTestProviderType)
                                       .SetNumberOfBrowserHosts(options.NumberOfBrowserHosts)
                                       .SetQueryString(options.QueryString)
                                       .SetWebBrowserType(options.WebBrowserType)
                                       .SetForceBrowserStart(options.ForceBrowserStart)
                                       .SetXapPaths(options.XapPaths)
                                       .SetDllPaths(options.Dlls)
                                       .SetReportOutputPath(options.XmlReportOutputPath)
                                       .SetReportOutputFileType(options.ReportOutputFileType)
                                       .SetContinuousIntegrationMode(options.ContinuousIntegrationMode)
                                       .SetOutputForTeamCity(options.OutputForTeamCity)
                                       .SetStartWebServerOnly(options.StartWebServerOnly)
                                       .SetIsRequestingDebug(options.IsRequestingDebug)
                    ;

                    TestReportCollection testReports = null;

                    try
                    {
                        TinyIoCContainer ioc = BootStrapper.Initialize(inputOptions);

                        var commandLineExecutionEngine = ioc.Resolve <RunnerExecutionEngine>();

                        testReports = commandLineExecutionEngine.Run();
                    }
                    catch (TinyIoCResolutionException tinyIoCResolutionException)
                    {
                        if (options.IsRequestingDebug)
                        {
                            throw;
                        }

                        throw ResolveNonTinyIocException(tinyIoCResolutionException);
                    }

                    if (testReports.FinalResult == RunCompletedState.Failure)
                    {
                        Environment.ExitCode = ExitFailed;
                    }
                    else
                    {
                        Environment.ExitCode = ExitSucceeded;
                    }
                }
                catch (AddressAccessDeniedException addressAccessDeniedException)
                {
                    Environment.ExitCode = ExitFailed;
                    var helpMessage = @"
Cannot run StatLight. The current account does not have the correct privilages.

Exception:
{0}

Try: (the following two steps that should allow StatLight to start a web server on the requested port)
     1. Run cmd.exe as Administrator.
     2. Enter the following command in the command prompt.
          netsh http add urlacl url=http://+:8887/ user=DOMAIN\user
".FormatWith(addressAccessDeniedException.Message);

                    WriteErrorToConsole(helpMessage, "Error");
                }
                catch (FileNotFoundException fileNotFoundException)
                {
                    HandleKnownError(fileNotFoundException);
                }
                catch (StatLightException statLightException)
                {
                    HandleKnownError(statLightException);
                }

                catch (Exception exception)
                {
                    HandleUnknownError(exception);
                }
            }
        }