PageRenderTime 13ms CodeModel.GetById 9ms app.highlight 2ms RepoModel.GetById 1ms 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//===================================================================================
17using System;
18using System.Collections.Generic;
19using System.Linq;
20using System.Text;
21using System.Windows.Automation;
22using System.Diagnostics;
23using AcceptanceTestLibrary.ApplicationObserver;
24using System.Text.RegularExpressions;
25using AcceptanceTestLibrary.ApplicationHelper;
26using System.IO;
27using System.Security.Policy;
28
29namespace AcceptanceTestLibrary.Common
30{
31    public class FixtureBase<TApp> 
32        where TApp : AppLauncherBase, new()
33    {
34        TApp appLauncher = new TApp();
35
36        private Process appProcess = null;
37
38        public List<AutomationElement> LaunchApplication(string applicationPath, string processTitle)
39        {
40            return appLauncher.LaunchApp(applicationPath, processTitle);
41        }
42
43        public void UnloadApplication(Process p)
44        {
45            appLauncher.UnloadApp(p);
46        }
47
48        #region Start - Stop Cassini Server
49        /// <summary>
50        /// Start the Cassini server from the given host path
51        /// </summary>
52        /// <param name="portNumber">Prt number of the server </param>
53        /// <param name="hostPath">Host path to launch the server from.</param>
54        public virtual void StartWebServer(string portNumber, string hostPath)
55        {
56            const string WEBSERVERPATH = @"\Common Files\microsoft shared\DevServer\9.0\webdev.webserver.exe";
57
58            appProcess = Process.Start(
59                    Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + WEBSERVERPATH,
60                    "/port" + portNumber + " /path:\"" + hostPath + "\"");
61        }
62
63        public virtual void StopWebServer()
64        {
65            appProcess.Kill();
66            appProcess = null;
67        }
68
69        
70        #endregion
71    }
72}