Esempio n. 1
0
        public static TinyIoCContainer Initialize(InputOptions inputOptions,
            ILogger overrideLogger = null)
        {
            if (inputOptions == null) throw new ArgumentNullException("inputOptions");
            var ioc = new TinyIoCContainer();
            ILogger logger = overrideLogger ?? GetLogger(inputOptions.IsRequestingDebug);
            ioc.Register(logger);

            ioc.Resolve<SettingsOverrideApplicator>()
                .ApplySettingsFrom(inputOptions.SettingsOverride, Properties.Settings.Default);

            inputOptions.DumpValuesForDebug(logger);
            ioc.Register(ioc);
            ioc.Register(inputOptions);
            ioc.Register<WebServerLocation>().AsSingleton();
            ioc.Register<IStatLightRunnerFactory, StatLightRunnerFactory>();

            var eventAggregator = ioc.Resolve<EventAggregatorFactory>().Create();
            ioc.Register(eventAggregator);
            ioc.Register<IEventPublisher>(eventAggregator);
            ioc.Register<IEventSubscriptionManager>(eventAggregator);

            ioc.Register<ResponseFactory>().AsSingleton();

            ioc.Register<IPostHandler, PostHandler>().AsSingleton();
            ioc.Register<ICurrentStatLightConfiguration, CurrentStatLightConfiguration>();

            return ioc;
        }
 public StatLightConfigurationFactory(ILogger logger, InputOptions options, WebServerLocation webServerLocation)
 {
     _logger = logger;
     _options = options;
     _webServerLocation = webServerLocation;
     _xapHostFileLoaderFactory = new XapHostFileLoaderFactory(_logger);
 }
        private static InputOptions CreateInputOptions(SilverlightTask silverlightTask, MethodTask[] testMethods)
        {
            var inputOptions = new InputOptions()
                .SetMethodsToTest(testMethods.Select(m => m.GetFullMethodName()))
                ;

            if (silverlightTask.HasXapPath())
                inputOptions.SetXapPaths(new[] {silverlightTask.GetXapPath()});
            else
                inputOptions.SetDllPaths(new[] {silverlightTask.GetDllPath()});
            return inputOptions;
        }
 public RunnerExecutionEngine(
     ILogger logger,
     IStatLightRunnerFactory statLightRunnerFactory,
     IEventPublisher eventPublisher,
     InputOptions inputOptions,
     ICurrentStatLightConfiguration currentStatLightConfiguration)
 {
     _logger = logger;
     _statLightRunnerFactory = statLightRunnerFactory;
     _eventPublisher = eventPublisher;
     _inputOptions = inputOptions;
     _currentStatLightConfiguration = currentStatLightConfiguration;
 }
Esempio n. 5
0
        protected override void Before_all_tests()
        {
            base.Before_all_tests();

            System.Diagnostics.Debug.Assert(ClientTestRunConfiguration != null);

            var options = new InputOptions()
                .SetUnitTestProviderType(ClientTestRunConfiguration.UnitTestProviderType)
                .SetXapPaths(new[] { GetTestXapPathInternal()})
                .SetMicrosoftTestingFrameworkVersion(MSTestVersion)
                .SetMethodsToTest(ClientTestRunConfiguration.MethodsToTest)
                .SetTagFilters(ClientTestRunConfiguration.TagFilter)
            ;

            _ioc = BootStrapper.Initialize(options, _testLogger);

            _eventSubscriptionManager = _ioc.Resolve<EventAggregator>();
            _statLightRunnerFactory = new StatLightRunnerFactory(_testLogger, _ioc);

            var currentStatLightConfiguration = _ioc.Resolve<ICurrentStatLightConfiguration>();
            StatLightConfiguration statLightConfiguration = currentStatLightConfiguration.Current;
            _testLogger.Debug("Setting up xaphost {0}".FormatWith(statLightConfiguration.Server.XapHostType));

            Runner = _statLightRunnerFactory.CreateOnetimeConsoleRunner(statLightConfiguration);
        }
Esempio 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);
                }
            }
        }
 public StatLightConfigurationFactory(ILogger logger, InputOptions options)
 {
     _logger  = logger;
     _options = options;
     _xapHostFileLoaderFactory = new XapHostFileLoaderFactory(_logger);
 }
 public StatLightConfigurationFactory(ILogger logger, InputOptions options)
 {
     _logger = logger;
     _options = options;
     _xapHostFileLoaderFactory = new XapHostFileLoaderFactory(_logger);
 }