I am trying to validate a header value exist in a response. Since ExtractHttpHeader only supports checking for the existence of header names and not values, I am traversing the test Context values looking for a specified key/value pair. I want to fail the web test if the values do not match.

How can I programmatically Fail a WebTest?
Ibrahim Dwaikat
e.Response.Headers[m_header]
header collection to check for the value at runtime in the Validate method of the rule.Good luck!
Ed.
Yusufp
Great response! Your recommendation was dead on. Here is the code snippet used in Validate() for anyone else needing to validate response header values:
for(int i = 0; i < e.Response.Headers.Keys.Count; ++i)
{
if (e.Response.Headers.GetKey(i) == HeaderStringParameterName)
{
string strVal = e.Response.Headers.Get(HeaderStringParameterName);
if (strVal == HeaderStringParameterExpectedValue)
{
e.IsValid = true;
e.Message = "Found";
break;
}
}
}