PageRenderTime 40ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/V4/AcceptanceTestLibrary/AcceptanceTestLibrary/Common/FixtureBase.cs

#
C# | 77 lines | 46 code | 10 blank | 21 comment | 0 complexity | a859fa69672e00c9cee2e3c6b7499f1b 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. public void UnloadApplication()
  44. {
  45. appLauncher.UnloadApp();
  46. }
  47. #region Start - Stop Cassini Server
  48. /// <summary>
  49. /// Start the Cassini server from the given host path
  50. /// </summary>
  51. /// <param name="portNumber">Prt number of the server </param>
  52. /// <param name="hostPath">Host path to launch the server from.</param>
  53. public virtual void StartWebServer(string portNumber, string hostPath)
  54. {
  55. const string WEBSERVERPATH = @"\Common Files\microsoft shared\DevServer\10.0\webdev.webserver40.exe";
  56. appProcess = Process.Start(
  57. Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + WEBSERVERPATH,
  58. "/port" + portNumber + " /path:\"" + hostPath + "\"");
  59. }
  60. public virtual void StopWebServer()
  61. {
  62. appProcess.Kill();
  63. appProcess = null;
  64. }
  65. #endregion
  66. }
  67. }