public void ValidateResponseReturnsFalseOnError() { HttpContextBase context = GetContext(); Assert.False(ReCaptcha.HandleValidateResponse(context, "false\nincorrect-captcha-sol")); Assert.Equal("incorrect-captcha-sol", ReCaptcha.GetLastError(context)); }
public void ValidateResponseReturnsFalseOnEmptyReCaptchaResponse() { HttpContextBase context = GetContext(); Assert.False(ReCaptcha.HandleValidateResponse(context, "")); Assert.Equal(String.Empty, ReCaptcha.GetLastError(context)); }
public void ValidateResponseReturnsTrueOnSuccess() { HttpContextBase context = GetContext(); Assert.True(ReCaptcha.HandleValidateResponse(context, "true\nsuccess")); Assert.Equal(String.Empty, ReCaptcha.GetLastError(context)); }
public void RenderUsesLastError() { HttpContextBase context = GetContext(); ReCaptcha.HandleValidateResponse(context, "false\nincorrect-captcha-sol"); var html = ReCaptcha.GetHtml(context, "PUBLIC_KEY"); AssertEqualsIgnoreLineBreaks( @"<script src=""http://api.recaptcha.net/challenge?k=PUBLIC_KEY&error=incorrect-captcha-sol"" type=""text/javascript""></script>" + @"<noscript>" + @"<iframe frameborder=""0"" height=""300"" src=""http://api.recaptcha.net/noscript?k=PUBLIC_KEY"" width=""500""></iframe><br></br>" + @"<textarea cols=""40"" name=""recaptcha_challenge_field"" rows=""3""></textarea>" + @"<input name=""recaptcha_response_field"" type=""hidden"" value=""manual_challenge""></input>" + @"</noscript>", html); }
public void RenderUsesLastError() { HttpContextBase context = GetContext(); ReCaptcha.HandleValidateResponse(context, "false\nincorrect-captcha-sol"); var html = ReCaptcha.GetHtml(context, "PUBLIC_KEY"); UnitTestHelper.AssertEqualsIgnoreWhitespace( @"<script src=""http://www.google.com/recaptcha/api/challenge?k=PUBLIC_KEY&error=incorrect-captcha-sol"" type=""text/javascript""></script>" + @"<noscript>" + @"<iframe frameborder=""0"" height=""300px"" src=""http://www.google.com/recaptcha/api/noscript?k=PUBLIC_KEY"" width=""500px""></iframe><br/><br/>" + @"<textarea cols=""40"" name=""recaptcha_challenge_field"" rows=""3""></textarea>" + @"<input name=""recaptcha_response_field"" type=""hidden"" value=""manual_challenge""/>" + @"</noscript>", html.ToString()); XhtmlAssert.Validate1_0(html, addRoot: true); }