Please update the sample code to reflect that RuleName and RuleDescription properties are obsolete.
using System;
using
Microsoft.VisualStudio.TestTools.WebTesting;
namespace
MyValidationRule
{
[DisplayName("Validate Script Existence")]
[Description("Validates that the page has a script.")]
public class
ValidatePageContainsScript : ValidationRule
{
public override void
Validate(object sender, ValidationEventArgs
e)
{
bool
validated =
false;
string foundJS
="";
string foundVBS =
"";
string message = "Non-valid HTML
document";
if (e.Response.HtmlDocument !=
null)
{ // Gets all input
tags
foreach (HtmlTag tag in
e.Response.HtmlDocument
.GetFilteredHtmlTags(new string[] { "script"
}))
{ // Check type of script for current
tag
if (tag.GetAttributeValueAsString("type") ==
"text/JavaScript")
foundJS = "Found
JavaScript";
if (tag.GetAttributeValueAsString("type") ==
"text/VBScript")
foundVBS = "Found
VBScript";
}
if (foundVBS.Length != 0 || foundJS.Length !=
0)
{
validated =
true;
message = string.Format("{0} {1}", foundJS,
foundVBS);
}
else
{
message = "No scripts in current
page";
}
}
e.IsValid =
validated;
e.Message = message;
}
}
}