PageRenderTime 52ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/V2.2/trunk/AcceptanceTestLibrary/AcceptanceTestLibrary/Common/FixtureBase.cs

#
C# | 72 lines | 42 code | 9 blank | 21 comment | 0 complexity | 5c67363f186e9b2dc62960cfd39a7df6 MD5 | raw file
  1. //===================================================================================
  2. // Microsoft patterns & practices
  3. // Composite Application Guidance for Windows Presentation Foundation and Silverlight
  4. //===================================================================================
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
  7. // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
  8. // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  9. // FITNESS FOR A PARTICULAR PURPOSE.
  10. //===================================================================================
  11. // The example companies, organizations, products, domain names,
  12. // e-mail addresses, logos, people, places, and events depicted
  13. // herein are fictitious. No association with any real company,
  14. // organization, product, domain name, email address, logo, person,
  15. // places, or events is intended or should be inferred.
  16. //===================================================================================
  17. using System;
  18. using System.Collections.Generic;
  19. using System.Linq;
  20. using System.Text;
  21. using System.Windows.Automation;
  22. using System.Diagnostics;
  23. using AcceptanceTestLibrary.ApplicationObserver;
  24. using System.Text.RegularExpressions;
  25. using AcceptanceTestLibrary.ApplicationHelper;
  26. using System.IO;
  27. using System.Security.Policy;
  28. namespace AcceptanceTestLibrary.Common
  29. {
  30. public class FixtureBase<TApp>
  31. where TApp : AppLauncherBase, new()
  32. {
  33. TApp appLauncher = new TApp();
  34. private Process appProcess = null;
  35. public List<AutomationElement> LaunchApplication(string applicationPath, string processTitle)
  36. {
  37. return appLauncher.LaunchApp(applicationPath, processTitle);
  38. }
  39. public void UnloadApplication(Process p)
  40. {
  41. appLauncher.UnloadApp(p);
  42. }
  43. #region Start - Stop Cassini Server
  44. /// <summary>
  45. /// Start the Cassini server from the given host path
  46. /// </summary>
  47. /// <param name="portNumber">Prt number of the server </param>
  48. /// <param name="hostPath">Host path to launch the server from.</param>
  49. public virtual void StartWebServer(string portNumber, string hostPath)
  50. {
  51. const string WEBSERVERPATH = @"\Common Files\microsoft shared\DevServer\9.0\webdev.webserver.exe";
  52. appProcess = Process.Start(
  53. Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + WEBSERVERPATH,
  54. "/port" + portNumber + " /path:\"" + hostPath + "\"");
  55. }
  56. public virtual void StopWebServer()
  57. {
  58. appProcess.Kill();
  59. appProcess = null;
  60. }
  61. #endregion
  62. }
  63. }