Ejemplo n.º 1
0
        protected TestExecutor(IHtmlPageBuilder htmlPageBuilder, ISerializationService serializationService, ITestResultsInformer testResultsInformer, ILogger logger, ICleanupManager cleanupManager)
        {
            _htmlPageBuilder = htmlPageBuilder;
            _serializationService = serializationService;
            _testResultsInformer = testResultsInformer;
            _logger = logger;
            _cleanupManager = cleanupManager;

            TestSessionId = Guid.NewGuid();

            WorkDirectory = Path.GetTempPath();

            if (!Directory.Exists(WorkDirectory))
            {
                Directory.CreateDirectory(WorkDirectory);
            }

            if (!Directory.Exists(CurrentTestSessionTempDirectory))
            {
                Directory.CreateDirectory(CurrentTestSessionTempDirectory);
            }
            _cleanupManager.DirectoriesToDelete.Add(CurrentTestSessionTempDirectory);

            _testResultsInformer.TestsExecutionFinished += OnInformerFinished;
            _testResultsInformer.TestsExecutionStarted += OnInformerStarted;
            _testResultsInformer.SilverlightTestingClientReady += OnRemoteTestEnvironmentReady;
            _testResultsInformer.TestingErrorOccured += OnInformerTestingErrorOccured;
            _testResultsInformer.LogMessageSentFromTestingEnvironment += (s, e) =>
                                                                             {
                                                                                 slideTheWatchdogTimer();
                                                                                 _logger.Log(e.Message);
                                                                             };
            _testResultsInformer.TestAssemblyStarted += (s, e) =>
                                                            {
                                                                slideTheWatchdogTimer();
                                                                _logger.Log(string.Format("Starting Assembly: {0}",
                                                                                          e.Assembly.Name));
                                                            };
            _testResultsInformer.TestAssemblyFinished += (s, e) =>
                                                             {
                                                                 slideTheWatchdogTimer();
                                                                 _logger.Log(string.Format("Finished Assembly: {0}",
                                                                                           e.Assembly.Name));
                                                             };
            _testResultsInformer.TestMethodStarted += (s, e) =>
                                                          {
                                                              slideTheWatchdogTimer();
                                                              _methodsStarted.Add(new TestMethodDetailedInformation() {Class = e.MethodDetailedInformation.Class, Method = e.MethodDetailedInformation.Method});
                                                              var msg = string.Format("[Started] {0}.{1}", e.MethodDetailedInformation.Class.Name, e.MethodDetailedInformation.Method.MethodName);
                                                              _logger.Log(msg);
                                                          };
            _testResultsInformer.TestMethodFinished += (s, e) =>
                                                           {
                                                               slideTheWatchdogTimer();
                                                               _methodsFinished.Add(new TestMethodDetailedInformation() { Class = e.Result.TestClass, Method = e.Result.TestMethod});
                                                               TestExecutionResults.UnitTestOutcome.TestResults.Add(e.Result);
                                                               var msg = new StringBuilder(string.Format("{0}.{1} [{2}] ",e.Result.TestClass.Name, e.Result.TestMethod.MethodName, e.Result.Result.ToString()));
                                                               if (e.Result.Result != UnitTestOutcome.Passed && e.Result.Exception != null)
                                                               {
                                                                   msg.AppendLine(e.Result.Exception.Message);
                                                               }

                                                               _logger.Log(msg.ToString());
                                                           };

            _webBrowser = new WebBrowser
                              {
                                  Dock = DockStyle.Fill,
                                  ObjectForScripting = _testResultsInformer,
                                  AllowNavigation = true,
                                  ScriptErrorsSuppressed = true
            };

            _form = new Form
            {
                Text = "SilverlightUnitTestRunner",
                Controls = { _webBrowser },
                Visible = false,
                WindowState = FormWindowState.Minimized,
                ShowInTaskbar = false
            };
        }
Ejemplo n.º 2
0
 public XapSourcedTestExecutor(IHtmlPageBuilder htmlPageBuilder, ISerializationService serializationService, IXapSourcedLighthouseXapBuilder xapBuilder, ITestResultsInformer testResultsInformer, ILogger logger, ICleanupManager cleanupManager)
     : base(htmlPageBuilder, serializationService, testResultsInformer, logger, cleanupManager)
 {
     _xapBuilder = xapBuilder;
 }