PageRenderTime 72ms CodeModel.GetById 60ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/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//===================================================================================
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        public void UnloadApplication()
49        {
50            appLauncher.UnloadApp();
51           
52        }
53        #region Start - Stop Cassini Server
54        /// <summary>
55        /// Start the Cassini server from the given host path
56        /// </summary>
57        /// <param name="portNumber">Prt number of the server </param>
58        /// <param name="hostPath">Host path to launch the server from.</param>
59        public virtual void StartWebServer(string portNumber, string hostPath)
60        {
61            const string WEBSERVERPATH = @"\Common Files\microsoft shared\DevServer\10.0\webdev.webserver40.exe";
62
63            appProcess = Process.Start(
64                    Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + WEBSERVERPATH,
65                    "/port" + portNumber + " /path:\"" + hostPath + "\"");
66        }
67
68        public virtual void StopWebServer()
69        {
70            appProcess.Kill();
71            appProcess = null;
72        }
73
74        
75        #endregion
76    }
77}