使用WatiN对ASP.NET页面进行单元测试[3]

发表于:2010-01-28来源:作者:点击数: 标签:单元AspWatiNNetNET
使用WatiN对ASP.NET页面进行单元测试[3] 单元测试工具 BaseTestPage类可以通过这些信息运行 服务器 ,所有继承了它的测试类都可以使用这个功能了。 下面是BaseTestPage类的完整代码: public class BaseTestPage { static Process server = null; static Bas

  使用WatiN对ASP.NET页面进行单元测试[3]   单元测试工具 

     BaseTestPage类可以通过这些信息运行服务器,所有继承了它的测试类都可以使用这个功能了。

  下面是BaseTestPage类的完整代码:

  public class BaseTestPage

  {

  static Process server = null;

  static BaseTestPage()

  {

  if (Process.GetProcessesByName("WebDev.WebServer").Length == 0)

  {

  string webServerExePath = (string)ConfigurationManager.AppSettings["WebServerExePath"];

  server = new Process();

  Process.Start(webServerExePath, GetWebServerArguments());

  }

  }

  public static string GetWebServerArguments()

  {

  string args = String.Format("/port:{0} /path:\"{1}\"", GetPort(), GetWebApplicationPath());

  if (String.IsNullOrEmpty(args)) throw new ArgumentNullException("Arguments is not defined");

  return args;

  }

  public static string GetPort()

  {

  string port = ConfigurationManager.AppSettings["Port"] as String;

  if (String.IsNullOrEmpty(port)) throw new ArgumentNullException("Port is null or empty");

  return port;

  }

  public static string GetWebApplicationPath()

  {

  string webApplicationPath = ConfigurationManager.AppSettings["WebApplicationPath"] as String;

  if (String.IsNullOrEmpty(webApplicationPath)) throw new ArgumentNullException("WebApplicationPath is null or empty");

  return webApplicationPath;

  }

原文转自:http://www.ltesting.net