假设如下:
[DataSource("SomeDataSource", "Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\SomeDataSource.xml", Microsoft.VisualStudio.TestTools.WebTesting.DataBindingAccessMethod.Sequential, Microsoft.VisualStudio.TestTools.WebTesting.DataBindingSelectColumns.SelectOnlyBoundColumns, "SomeTable")]
[DataBinding("SomeDataSource", "SomeTable", "SomeColumn", "SomeContextParamter")]
public abstract WebTestBase: WebTest
{
protected IList<WebTestRequest> _requests = new List<WebTestRequest>();
public WebTestBase()
{
this.PreAuthenticate = true;
this.Proxy = "default";
}
public override IEnumerator<WebTestRequest> GetRequestEnumerator()
{
// Error: Parameter doesn't exist in context.
string parameter = this.Context["SomeContextParameter"].ToString();
this.CreateRequests();
// Some more code.
}
protected abstract IEnumerable<WebTestRequest> CreateRequests();
}
[CodedWebTest]
public DerivedWebTest: WebTestBase
{
protected override IEnumerable<WebTestRequest> CreateRequests()
{
// Error: Parameter doesn't exist in context.
string parameter = this.Context["SomeParameter"].ToString();
// Some more code.
}
}
这是从数据源正确加载到Context属性,就像应用DataBindingAttribute时一样。
有什么想法吗?