【发布时间】:2011-03-05 04:41:15
【问题描述】:
以下测试:
[TestClass]
public class MyTestClass
{
private TestContext _testContext;
protected TestContext TestContext
{
get { return _testContext; }
set { _testContext = value; }
}
[TestMethod]
[HostType("ASP.NET")]
[UrlToTest("http://localhost/MyPage.aspx")]
public void TestMyPage()
{
TextBox tb = TestContext.RequestedPage.FindControl("ControlId") as TextBox;
Assert.IsNotNull(tb);
}
}
失败,并且使用字符串“ctl00$ContentPlaceHolder1$ControlId”作为控件 ID 提供了适当的控件...我知道,ASP.NET 包含用于 Web 控件的“ClientID”属性,但是否有可能知道在 TEST 中推进控件的客户端 ID(VS 2008 下)?
谢谢。
【问题讨论】:
标签: asp.net unit-testing testing