Start() public méthode

Starts the test service hosting thread.
public Start ( ) : void
Résultat void
Exemple #1
0
        public bool Run()
        {
            try
            {
                Failures = -1;
                string page = Options.Page;
                string path = Options.LocalPath;
                if (File.Exists(path))
                {
                    FileInfo fi = new FileInfo(path);
                    TestService.RootDirectory = fi.DirectoryName;
                }
                else if (Directory.Exists(path))
                {
                    TestService.RootDirectory = path;
                }

                TestService.TestRunPrefix = Options.DeviceInfo.DeviceId.ToString();
                TestService.Start();
                if (!string.IsNullOrEmpty(Options.TagExpression))
                {
                    TestService.TagExpression = Options.TagExpression;
                }
                if (!string.IsNullOrEmpty(Options.Log))
                {
                    TestService.LogFile = Options.Log;
                }

                TargetDevice = Options.DeviceInstance ?? new TargetDevice(Options.DeviceInfo);

                TargetDevice.Start(Options.ApplicationProductId, Options.ApplicationGenre,
                                   Options.XapFile, Options.UpdateApplication);

                while (TestService.IsRunning && TargetDevice.IsRunning && TestService.Result == null)
                {
                    Thread.Sleep(TimeSpan.FromMilliseconds(PollingThreadSleepMilliseconds));
                }

                TestRunResult result = TestService.Result;
                if (result != null)
                {
                    Total    = result.Total;
                    Log      = result.Log;
                    Failures = result.Failures;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                Thread.Sleep(TimeSpan.FromMilliseconds(FinalSleepDelayMilliseconds));
                TargetDevice.Close();
                TestService.Stop();
            }
            return(Failures == 0);
        }
        public bool Run()
        {
            try
            {
                Failures = -1;
                string page = Options.Page;
                string path = Options.LocalPath;
                if (File.Exists(path))
                {
                    FileInfo fi = new FileInfo(path);
                    TestService.RootDirectory = fi.DirectoryName;
                    page = fi.Name;
                }
                else if (Directory.Exists(path))
                {
                    TestService.RootDirectory = path;
                    if (!File.Exists(Path.Combine(path, page)))
                    {
                        page = string.Empty;
                    }
                }
                TestService.TestRunPrefix = Options.Browser.ToString();
                TestService.Start();
                if (!string.IsNullOrEmpty(Options.TagExpression))
                {
                    TestService.TagExpression = Options.TagExpression;
                }
                if (!string.IsNullOrEmpty(Options.Log))
                {
                    TestService.LogFile = Options.Log;
                }

                WebBrowser = Options.BrowserInstance != null ? Options.BrowserInstance : WebBrowserFactory.Create(Options.Browser);

                Uri uri = new Uri(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        StandardLocalHostingUrl,
                        _testServiceOptions.MachineName,
                        _testServiceOptions.Port,
                        page,
                        Options.RunId));

                WebBrowser.Start(uri);

                while (TestService.IsRunning && WebBrowser.IsRunning && TestService.Result == null)
                {
                    Thread.Sleep(TimeSpan.FromMilliseconds(PollingThreadSleepMilliseconds));
                }

                TestRunResult result = TestService.Result;
                if (result != null)
                {
                    Total    = result.Total;
                    Log      = result.Log;
                    Failures = result.Failures;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                Thread.Sleep(TimeSpan.FromMilliseconds(FinalSleepDelayMilliseconds));
                WebBrowser.Close();
                TestService.Stop();
            }
            return(Failures == 0);
        }