Exemple #1
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);
                }
            }
        }
Exemple #2
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);
                }
            }
        }