Enterprise Library Test Guide - Willy .Net
Enterprise Library Test Guide - Willy .Net
Enterprise Library Test Guide - Willy .Net
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Test</strong>ing for Performance and Scalability 179<br />
viewState = this.Context["$HIDDEN1.__VIEWSTATE"].ToString();<br />
EventValidation = this.Context["$HIDDEN1.__EVENTVALIDATION"].ToString();<br />
}<br />
String KeyValueString;<br />
// The object is locked and the keyvalue is incremented.<br />
// It is stored in a local variable<br />
// and used in the post statement.<br />
// This is only applicable to the Caching Application Block.<br />
lock (lockn)<br />
{<br />
KeyValueString = KeyValue.ToString();<br />
KeyValue++;<br />
if (KeyValue > MaxElements)<br />
KeyValue = 1;<br />
}<br />
// A timer is set to measure transaction times.<br />
this.BeginTransaction("Caching_Entlib20");<br />
Web<strong>Test</strong>Request request2 = new Web<strong>Test</strong>Request("http://10.3.16.10/EntLib/Caching/<br />
Caching.aspx");<br />
request2.Method = "POST";<br />
FormPostHttpBody request2Body = new FormPostHttpBody();<br />
// Add the ViewState hidden filed to the body of the request.<br />
request2Body.FormPostParameters.Add("__VIEWSTATE", ViewState);<br />
request2Body.FormPostParameters.Add("txtBoxKeyValue", KeyValue);<br />
request2Body.FormPostParameters.Add("txtBoxCacheSize", "2000");<br />
request2Body.FormPostParameters.Add("ddlCacheManager","DefaultCacheManager");<br />
request2Body.FormPostParameters.Add("ddlExpirationType", "0");<br />
request2Body.FormPostParameters.Add("ddlPriority", "0");<br />
request2Body.FormPostParameters.Add("btnAddItemToCache", "Add Item");<br />
// Add the EventValidation hidden field to the body of the request.<br />
request2Body.FormPostParameters.Add("__EVENTVALIDATION", EventValidation);<br />
request2.Body = request2Body;<br />
yield return request2;<br />
this.EndTransaction("Caching_Entlib20");<br />
}<br />
Using Data Binding<br />
With data binding, you can use a data source to provide data for a Web test. You can<br />
bind data from the data source to a part of a Web request that requires data, such as<br />
a form post parameter. For example, in the Caching Application Block Web test, you<br />
can set the value of the cache storage (this can be either SqlCacheManager or DefaultCacheManager)<br />
in the data source and then pass this value to the Web test at<br />
run time. The Cache Manager drop-down list will show the correct cache manager as<br />
selected. You can use any OLE DB data source for data binding, including .csv files,<br />
Microsoft Excel, Access and SQL Server databases.<br />
To use data binding, first create a database table or a .csv file that contains the data<br />
that will be bound to the Web control. The first row in the column is a name and the<br />
subsequent rows are the values. For example, to data bind values to the drop-down