如何以编程方式将数据绑定添加到Web性能测试?

时间:2015-09-25 09:31:44

标签: c# web-testing

假设如下:

[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时一样。

有什么想法吗?

0 个答案:

没有答案