NUnitAsp and WebForm_PostBackOptions
I've decide to use NUnitAsp on the current project.
After doing some basic visibility checks I tried to call Click() on a LinkButtonTester and I got an error.
I did some digging and found that the new WebForm_PostBackOptions was not being recognized as a postback.
With a bit of hacking around, I've got it working again, the biggest issue was different quotes in the postBackScript from those in the html.
The fix:I'm not sure how comprehensive it is, but the basic fix is 2 changes in WebFormTester:
public bool IsPostBack(string candidatePostBackScript){
bool postback = (candidatePostBackScript.IndexOf("__doPostBack") != -1)|| (candidatePostBackScript.IndexOf(
"WebForm_PostBackOptions") != -1);return (candidatePostBackScript != null) && postback ;}
and
public void PostBack(string postBackScript){
string postBackPattern1 = @"__doPostBack\('(?<target>.*?)','(?<argument>.*?)'\)"; string postBackPattern2 = @"__doPostBack\(\\'(?<target>.*?)\\',\\'(?<argument>.*?)\\'\)";string postBackPattern3 = @"WebForm_PostBackOptions\(""(?<target>.*?)"", ""(?<argument>.*?)""";bool succeeded = TryPostBack(postBackScript, postBackPattern1); if (!succeeded) succeeded = TryPostBack(postBackScript, postBackPattern2);if (!succeeded) succeeded = TryPostBack(postBackScript, postBackPattern3); //if (!succeeded) succeeded = TryPostBack(postBackScript, postBackPattern4);if (!succeeded)
{
throw new ParseException("'" + postBackScript + "' doesn't match expected patterns for postback in " + Description);}
}