public AccountStatus Logining(ref Captcha captcha) { // Если это первое обращение, то устанавливаем новые куки. if (captcha == null) { Cookies = new CookieDictionary(); Request.Cookies = Cookies; } Request.AddParam("login", Login).AddParam("password", Password); // Если до этого требовался ввод капчи. if (captcha != null) { Request.AddParam("c_key", captcha.Key); } string loginingResult = Request.Post("/logining.php").ToString(); // Если требуется ввод капчи. if (loginingResult.Contains("need_captcha")) { string captchaUrl = loginingResult.Substring("captcha_url=", "&"); captcha = new Captcha(captchaUrl); return AccountStatus.None; } if (loginingResult.Contains("ok")) { return AccountStatus.Valid; } return AccountStatus.NotValid; }
public ActionResult Captcha() { Session[Infrastructure.Captcha.CaptchaValueKey] = RandomUtil.GetRandomString(4); var captcha = new Captcha(Session[Infrastructure.Captcha.CaptchaValueKey].ToString(), 250, 100, FontFamily.Families.ElementAt(/*RandomUtil.GetRandomInt(FontFamily.Families.Length - 1)*/1).Name); Response.Clear(); Response.ContentType = "image/jpeg"; captcha.Image.Save(Response.OutputStream, ImageFormat.Jpeg); captcha.Dispose(); return null; }
public IActionResult Create([Bind("FirstName,LastName,Email,Password,ControlPassword,CaptchaCode")] RegisterModel registerModel) { if (ModelState.IsValid == false) { _logger.LogWarning("Register user failed because of invalid ModelState"); return(View(registerModel)); } if (registerModel.Password.Equals(registerModel.ControlPassword) == false) { _logger.LogInformation("Register user failed because of mismatch between password and confirm password"); ModelState.AddModelError(string.Empty, "Password and Confirm Password do not match"); return(View(registerModel)); } if (ValidatePassword(registerModel.Password) == false) { _logger.LogInformation("Register user failed because of password requirements that were not met"); ModelState.AddModelError(string.Empty, "Password must be at least 8 charachters containing uppercase and lowercase letters and at least one number and one special character!"); return(View(registerModel)); } if (Captcha.ValidateCaptchaCode(registerModel.CaptchaCode, HttpContext)) { try { User user = new User { FirstName = registerModel.FirstName, LastName = registerModel.LastName, Email = registerModel.Email, Role = "User", }; var hasher = new PasswordHasher <User>(); user.PasswordHash = hasher.HashPassword(user, registerModel.Password); _userManager.AddUser(user); _logger.LogInformation("Registered new user with emailaddress: {email}", registerModel.Email); return(RedirectToAction("UserRegistrationCompleted", "Home")); } catch (Exception) { return(View(registerModel)); } } else { _logger.LogInformation("Register user failed because of wrong captcha code"); ModelState.AddModelError(string.Empty, "Wrong Captcha Code. Try again!"); return(View(registerModel)); } }
private async void LoginBtn_Click(object sender, RoutedEventArgs e) { DisableLoginBtn(); bool success = await TryLogin(); if (useCaptcha) { Captcha.Show(captchaSvg); return; } EnableLoginBtn(); TryLeave(success); }
public static string Getcapchar() { Client client = (Client) new SocketClient("ntdong", "ntdong"); client.Balance.ToString(); Captcha captcha = client.Decode("capchar.Bmp", 50, (Hashtable)null); if (captcha.Solved && captcha.Correct) { return(captcha.Text); } return((string)null); }
private void DebugCaptcha(byte[] image, Captcha captchaResult) { var guid = Guid.NewGuid(); var fileName = string.Format("{0}-{1}", guid, captchaResult.Text); File.WriteAllBytes(fileName + ".jpg", image); var captchaText = string.Format("Id={0}\nCorrect={1}\nText={2}\nSolved={3}\nUploaded={4}", captchaResult.Id, captchaResult.Correct, captchaResult.Text, captchaResult.Solved, captchaResult.Uploaded); File.WriteAllText(fileName + ".txt", captchaText); }
/// <summary> /// Get request to generate new Captcha Image, return Image Path and Code /// GET: api/Captcha /// </summary> /// <returns></returns> public Captcha Get() { Captcha captcha = new Captcha(); if (cls.GenerateCaptcha()) { captcha.CaptchaImagePath = cls.ImageFilePath; captcha.CaptchaCode = cls.GeneratedCode; return(captcha); } return(null); }
public string Discern(Captcha captcha) { string code = OnNority(captcha); Console.WriteLine(code); if (code == null) { return(null); } PublishRedisMessage(); PublishMongoMessage(); return(code); }
internal bool PostCaptcha(User user, Captcha captcha, int[] answer) { string url = "https://" + Links.ApiBaseUrl + "/api/" + Version + Url + user.Token.Token; string an = string.Join(",", answer ?? new int[0]); string payload = @"{""key"":""" + captcha.Key + @""",""answer"":[" + an + "]}"; var myClient = new WebClient(); myClient.Headers.Add("Content-Type", "application/json"); var json = JObject.Parse(myClient.UploadString(url, payload)); return(json.Value <bool>("verified")); }
public string SolveUrl(string url) { using (WebClient clientHttp = new WebClient()) { byte[] data = clientHttp.DownloadData(url); captcha = client.Decode(data); if (captcha == null || !captcha.Solved) { return(null); } return(captcha.Text); } }
public Base <object> SendCaptcha(Captcha model) { Meta meta = new Meta(); SendCaptchas(model, ref meta); Base <object> response = new Base <object> { Meta = meta, Body = null }; return(response); }
public void GeneratedImageOptions_DuplicateFree() { for (var i = 0; i < 100; i++) { var captcha = new Captcha(10); var optionValues = new List <string>(); foreach (var option in captcha.PossibleImageOptions) { Assert.IsFalse(optionValues.Contains(option.Key), string.Format("Duplicate option found: {0}", option.Key)); optionValues.Add(option.Key); } } }
public IActionResult Get() { int width = 100; int height = 36; var captchaCode = Captcha.GenerateCaptchaCode(); var result = Captcha.GenerateCaptchaImage(width, height, captchaCode); HttpContext.Session.SetString("key", result.CaptchaCode); // CaptchaController.code = HttpContext.Session.GetString("key"); Stream s = new MemoryStream(result.CaptchaByteData); return(new FileStreamResult(s, "image/png")); }
public ActionResult GetAuthCode() { Captcha captcha = new Captcha(); captcha.FontSize = 24; Session["Code"] = captcha.Code; return(File(captcha.Image(), @"image/Gif")); //AuthCode ac = new AuthCode(); //Session["Code"] = ac.Code; //byte[] bs = ac.DrawCode().ToArray(); //return File(bs, @"image/Gif"); }
private IRestResponse upload(Captcha captcha, byte[] binary) { var client = new RestClient("http://api.ruokuai.com/create.json"); var request = new RestRequest(Method.POST); request.AddParameter("username", RemoteUser.RuoKuai); request.AddParameter("password", Constant.RemotePassword); request.AddParameter("typeid", captcha.Channel.Substring(captcha.Channel.Length - 4, 4)); request.AddParameter("softid", RemoteUser.RuoKuaiSoftId); request.AddParameter("softkey", RemoteUser.RuoKuaiSoftKey); request.AddFileBytes("image", binary, "captcha.jpg", "image/jpeg"); return(client.Execute(request)); }
public void InvalidImageOptions_Fail() { for (var i = 0; i < 100; i++) { var captcha = new Captcha(5); var data = captcha.GetFrontEndData(); foreach (var option in data.Values.Where(option => option != captcha.ValidImageOption.Value)) { Assert.IsFalse(captcha.ValidateAnswer(option)); } } }
public static bool Sms(string name, int type, DataSource ds) { try { PassportSection section = PassportSection.GetSection(); if (!section.VerifyMobile) { throw new Exception(); } HttpRequest Request = HttpContext.Current.Request; string captcha = Request.Form["Captcha"]; if (!string.IsNullOrEmpty(captcha)) { if (!Captcha.CheckCaptcha(Request.Form["CaptchaName"], captcha)) { throw new Exception(); } } long mobile = long.Parse(Request.Form["Mobile"]); int timespan = SMSCaptchaSection.GetSection().TimeSpan; MobileHash hash = MobileHash.Create(ds, mobile, type, timespan); if (hash == null) { throw new Exception(); } string md5 = string.Concat(Request.UserHostAddress, "\r\n", Request.UserAgent).MD5(); StringHash sh = StringHash.Create(ds, md5, StringHash.SmsHash, timespan); if (sh == null) { throw new Exception(); } SmsTemplate temp = SmsTemplate.GetByName(ds, SmsTemplate.Register); if (temp.Type == SmsTemplateType.Template) { SendTemplateImpl(name, mobile, temp.Content, ds, hash.Hash); } else { SendImpl(name, mobile, temp.Content, ds, hash.Hash); } return(true); } catch (Exception) { return(false); } }
public IActionResult CaptchaImageLoading() { // 5 Harfli 140x40 boyutlarında Captcha oluşturuluyor. var captchaResult = Captcha.GenerateCaptcha(140, 40, 5); // Oluşturulan Captcha için kodu, oturum oluşturarak "CaptchaCode", string'inde tutuyoruz. HttpContext.Session.SetString("CaptchaCode", captchaResult.CaptchaStringCode); // Bellekten resmimize ulaşıyoruz. Stream stream = new MemoryStream(captchaResult.CaptchaByteDatas); // Resmi Gif formatında gönderiyoruz. return(new FileStreamResult(stream, "image/gif")); }
public string SolveBase64(string data) { int from = data.IndexOf("base64,") + "base64,".Length; data = data.Substring(from); byte[] imageBytes = Convert.FromBase64String(data); captcha = client.Decode(imageBytes); if (captcha == null || !captcha.Solved) { return(null); } return(captcha.Text); }
protected void Page_Load(object sender, EventArgs e) { int captchaWidth = (!int.TryParse(Request.QueryString["w"], out captchaWidth)) ? 175 : int.Parse(Request.QueryString["w"]); int captchaHeight = (!int.TryParse(Request.QueryString["h"], out captchaHeight)) ? 35 : int.Parse(Request.QueryString["h"]); Captcha.caseSensitive = false; Captcha ci = new Captcha(captchaWidth, captchaHeight); Response.Clear(); Response.ContentType = "image/jpeg"; ci.Image.Save(Response.OutputStream, ImageFormat.Jpeg); ci.Dispose(); }
public void Generate() { CaptchaModel model = Captcha.Generate(); CorrectX = model.X; //pb2.Size = new Size(model.Slide.Width, model.Slide.Height); //pb1.Size = new Size(model.Background.Width, model.Background.Height); pb2.Image = model.Slide; pb1.Image = model.Background; Bitmap bitmap = (Bitmap)model.Background; Color color = bitmap.GetPixel(bitmap.Width - lblRefresh.Width, lblRefresh.Height); lblRefresh.ForeColor = Captcha.AntiColor(color); }
public ActionResult Captcha() { Session[Infrastructure.Captcha.CaptchaValueKey] = new Random(DateTime.Now.Millisecond).Next(1111, 9999).ToString(CultureInfo.InvariantCulture); var ci = new Captcha(Session[Infrastructure.Captcha.CaptchaValueKey].ToString(), 211, 50, "Helvetica"); this.Response.Clear(); this.Response.ContentType = "image/jpeg"; ci.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg); ci.Dispose(); return(null); }
private IRestResponse upload(Captcha captcha, byte[] binary) { var client = new RestClient("http://v1-http-api.jsdama.com/api.php?mod=php&act=upload"); var request = new RestRequest(Method.POST); request.AddParameter("user_name", RemoteUser.LianZhong); request.AddParameter("user_pw", Constant.RemotePassword); request.AddFileBytes("upload", binary, "captcha.jpg", "image/jpeg"); request.AddParameter("yzmtype_mark", captcha.Channel.Substring(captcha.Channel.Length - 4, 4)); request.AddParameter("yzm_minlen", "4"); request.AddParameter("yzm_maxlen", "4"); request.AddParameter("zztool_token", RemoteUser.LianZhong); return(client.Execute(request)); }
/// <summary>生成流水号</summary> /// <param name="doc">Xml 文档对象</param> /// <returns>返回操作结果</returns> public string CreateNewObject(XmlDocument doc) { StringBuilder outString = new StringBuilder(); string base64String = string.Empty; string key = XmlHelper.Fetch("key", doc); string widthText = XmlHelper.Fetch("width", doc); int width = string.IsNullOrEmpty(widthText) ? 100 : Convert.ToInt32(widthText); string heightText = XmlHelper.Fetch("height", doc); int height = string.IsNullOrEmpty(heightText) ? 50 : Convert.ToInt32(heightText); // 初始化验证码 Captcha captcha = new Captcha(new { Width = width, // image width in pixels Height = height, // image height in pixels // Foreground = Color.Black, // font color; html color (#RRGGBB) or System.Drawing.Color Background = Color.White, // background color; html color (#RRGGBB) or System.Drawing.Color KeyLength = 5, // key length Waves = true, // enable waves filter (distortions) Overlay = true // enable overlaying }); using (MemoryStream stream = new MemoryStream()) { captcha.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Png); byte[] buffer = new byte[stream.Length]; stream.Position = 0; stream.Read(buffer, 0, (int)stream.Length); stream.Close(); base64String = Convert.ToBase64String(buffer); } if (string.IsNullOrEmpty(key)) { HttpContext.Current.Session["captcha"] = captcha.Key; } else { HttpContext.Current.Session["captcha-" + key] = captcha.Key; } return("{\"data\":{\"width\":" + captcha.Image.Width + ",\"height\":" + captcha.Image.Height + ",\"base64\":\"" + base64String + "\"},\"message\":{\"returnCode\":0,\"value\":\"创建成功。\"}}"); }
public ActionResult Create() { var captcha = Captcha.GetCaptcha(); ViewBag.Base64String = captcha[0]; ViewBag.Answer = captcha[1]; ViewBag.Message = ""; ViewBag.MessageColor = ""; ViewBag.ProgramId = new SelectList(db.Programs, "Id", "ShortName"); return(View()); }
public ActionResult CaptchaImage() { Captcha captcha = Captcha.Current; if (captcha == null) { return(Content(string.Empty)); } System.Drawing.Bitmap bitmap = captcha.CreateImage(); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png); return(new FileContentResult(memoryStream.ToArray(), "image/png")); }
public FileStreamResult GetImage() { int width = 200; int height = 60; var captchaCode = Captcha.GenerateCaptchaCode(); var result = Captcha.GenerateCaptchaImage(width, height, captchaCode); HttpContext.Session.SetString("CaptchaCode", result.CaptchaCode); Stream s = new MemoryStream(result.CaptchaByteData); return(new FileStreamResult(s, "image/png")); }
public ActionResult Index(FormCollection form) { var account = form["Account"]; var pasword = form["Password"]; var code = form["ValidateCode"]; if (string.IsNullOrWhiteSpace(account) || string.IsNullOrWhiteSpace(pasword) || string.IsNullOrWhiteSpace(code)) { return(Json(new { success = false, msg = "账户名/密码为空" }, JsonRequestBehavior.AllowGet)); } account = account.Trim(); pasword = pasword.Trim(); code = code.Trim(); if (!Captcha.CompareAndDestroy(Session, code)) { return(Json(new { success = false, msg = "验证码错误" }, JsonRequestBehavior.AllowGet)); } var tenant = new Tenant() { Account = account, AccountType = (int)TenantAccountType.Email, Password = pasword, Email = account, Owner = new DBC.WeChat.Models.Infrastructures.Store() { Enabled = false } }; var svc = ServiceLocator.Resolve <IModelService>("Internal"); try { svc.Create(tenant); tenant.CreatorID = null; tenant.LastModifiedAt = null; tenant.LastModifierID = null; RegEmail.Send(tenant, Request); Session["Tenant"] = tenant; } catch (RuleViolatedException ex) { return(Json(new { success = false, msg = ex.Message }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, msg = "未知错误" }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); }
private void OnValid(bool ret) { var result = ret ? "成功" : "失败"; Trace?.Log($"验证码结果 -> {result}"); if (ret) { Task.Run(async() => { await Task.Delay(1000); Captcha?.Reset(); }); } }
/// <summary> /// Валидация при регистрации /// </summary> /// <param name="userName">Логин</param> /// <param name="email">E-Mail</param> /// <param name="password">Пароль</param> /// <param name="confirmPassword">Подтверждение пароля</param> /// <param name="context">Контекст (для captcha)</param> /// <param name="captcha">Идентификатор ответа на captcha</param> /// <param name="attempt">Ответ на captcha</param> /// <returns>Результат валидации</returns> private bool ValidateRegistration(string userName, string email, string password, string confirmPassword, HttpContextBase context, string captcha, string attempt) { var manager = new UserManager(_userRepository, _roleRepository, _contactsRepository, _unitOfWork); if (!ValidateUserName(userName)) { ModelState.AddModelError("userName", "Некорректный логин"); } if (!Captcha.VerifyAndExpireSolution(context, captcha, attempt)) { ModelState.AddModelError("captcha", "Неверно указан код от автоматической регистрации."); } if (string.IsNullOrEmpty(email)) { ModelState.AddModelError("email", "Введите E-Mail."); } else { if (email.Length > 30) { ModelState.AddModelError("email", "E-Mail должен содержать не более 30 символов."); } if (!Regex.IsMatch(email, @"^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$")) { ModelState.AddModelError("email", "Введите корректный E-Mail."); } var user = manager.GetUserByEmail(email); if (user != null) { ModelState.AddModelError("_FORM", "Такой email уже зарегистрирован."); return(ModelState.IsValid); } } if (string.IsNullOrEmpty(password) || password.Length < _passwordMinLength) { ModelState.AddModelError("password", String.Format(CultureInfo.CurrentCulture, "Пароль должен содержать {0} или более символов.", _passwordMinLength)); } if (!String.Equals(password, confirmPassword, StringComparison.Ordinal)) { ModelState.AddModelError("_FORM", "Новый пароль и подтверждение пароля должны совпадать."); } return(ModelState.IsValid); }
public JsonResult SubmitRequireResetPassword() { /*userName: userName, email: email, captchaCode: captchaCode, captchaId: captchaId, instanceId: instanceId*/ string userName = Request["userName"]; string email = Request["email"]; string captchaCode = Request["captchaCode"]; string captchaId = Request["captchaId"]; string instanceId = Request["instanceId"]; //数据验证 Regex regex = new Regex("^[0-9a-zA-Z._-]+[@][0-9a-zA-Z_-]+([.][a-zA-Z]+){1,2}$"); if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(email) || !regex.IsMatch(email)) { return(Json(new { Status = "error", Msg = "data error" }, JsonRequestBehavior.AllowGet)); } //校验验证码 if (!Captcha.AjaxValidate(captchaId, captchaCode, instanceId)) { return(Json(new { Status = "error", Msg = "验证码错误" }, JsonRequestBehavior.AllowGet)); } //校验数据正确性 User user = new UserBLL().GetByUserName(userName); if (user == null || user.Id <= 0 || user.Email != email) { return(Json(new { Status = "error", Msg = "用户名与邮箱不匹配" }, JsonRequestBehavior.AllowGet)); } //发送重置密码邮件 string guid = Guid.NewGuid().ToString(); string url = "http://localhost:5555/UserOperation/ResetPassword?id=" + guid; string body = string.Format("请点击以下链接进行密码重置:<br/><a href='{0}'>{0}</a>", url); EmailModel model = new EmailModel() { MailTo = email, Subject = "SharePlat用户密码重置邮件", Body = body }; string data = JsonConvert.SerializeObject(model); RedisHelper.Enqueue("sendResetPwdEmail", data); //使用Redis消息队列发送密码重置邮件 RedisHelper.Set <string>(guid, user.Id.ToString(), 20); //设置重置邮件有效期 return(Json(new { Status = "ok", Msg = "" }, JsonRequestBehavior.AllowGet)); }
public void Render(string challengeGuid) { string solution = (string)Session[SessionKeys.CaptchaSessionPrefix + challengeGuid]; using (Bitmap bmp = Captcha.RenderCaptcha(solution)) { Response.ContentType = "image/jpeg"; Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1)); Response.Cache.SetValidUntilExpires(false); Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore(); bmp.Save(Response.OutputStream, ImageFormat.Jpeg); } }
public ActionResult Index(User user, Captcha captcha) { //Sessin contains expected captcha value. if (captcha == null || Session["Captcha"] == null || Session["Captcha"].ToString() != captcha.CaptchaResult) { ModelState.AddModelError("Captcha", "Wrong captcha value. Try again."); //display error and generate a new captcha return View(); } //check user here! //if (CoreWrapper.Instance.UserExists(user.Login)) //{ FormsAuthentication.SetAuthCookie(user.Login, true); return RedirectToAction("Index", "Admin"); //} //return View(); }
/// <summary> /// <para>Gets and sets a <see cref="Captcha" /> .</para> /// </summary> /// <param name="uri"></param> /// <param name="captcha"></param> public void UpdateCaptchaData( Captcha captcha ) { if ( null == captcha || null == captcha.Uri ) { return; } this._captchaDatabase[ captcha.Uri.AbsoluteUri ] = captcha; }
public Captcha PullCaptchaData( [NotNull] Uri uri ) { if ( uri == null ) { throw new ArgumentNullException( "uri" ); } if ( null == this._captchaDatabase[ uri.AbsoluteUri ] ) { var captcha = new Captcha { Uri = uri }; this._captchaDatabase[ uri.AbsoluteUri ] = captcha; } return this._captchaDatabase[ uri.AbsoluteUri ]; }
public void RightOperand_ShouldBeONE_WhenInputIs1() { Captcha captcha = new Captcha(2, 1, 1, 1); Assert.AreEqual("ONE", captcha.GetRightOperand()); }
public void Operator_ShouldThrowArgumentOutOfRangeException_WhenInputNotIn1To3() { Captcha captcha = new Captcha(2, 1, 0, 10); Assert.Throws<ArgumentOutOfRangeException>(() => captcha.GetOperator()); captcha = new Captcha(2, 1, 4, 10); Assert.Throws<ArgumentOutOfRangeException>(() => captcha.GetOperator()); }
public void Get_ShouldBe1MultiplyOne_WhenPatternIs2_LeftOperandIs1_OperatorIs2_RightOperandIs1() { var captcha = new Captcha(2, 1, 2, 1); Assert.AreEqual("1 * ONE", captcha.Get()); }
public void RightOperand_ShouldThrowArgumentOutOfRangeException_WhenPatternIs1AndRightOperandIs10() { Captcha captcha = new Captcha(1, 1, 1, 10); Assert.Throws<ArgumentOutOfRangeException>(() => captcha.GetRightOperand()); }
public void Operator_ShouldBePlus_WhenInputIs1() { Captcha captcha = new Captcha(pattern: 2, leftOperand: 1, operatorValue: 1, rightOperand: 1); Assert.AreEqual("+", captcha.GetOperator()); }
public void LeftOperand_ShouldBeTWO_WhenPatternIs1AndLeftOperandIs2() { var captcha = new Captcha(1, 2, 1, 1); Assert.AreEqual("TWO", captcha.GetLeftOperand()); }
public void LeftOperand_ShouldThrowArgumentOutOfRangeException_WhenInputIsMinus1() { Captcha captcha = new Captcha(2, -1, 1, 1); Assert.Throws<ArgumentOutOfRangeException>(() => captcha.GetLeftOperand()); }
public void LeftOperand_ShouldBe9_WhenInputIs9() { Captcha captcha = new Captcha(2, 9, 1, 1); Assert.AreEqual("9", captcha.GetLeftOperand()); }
private void SetCaptcha() { // Set image string s = new Captcha().GenerateSolution(null); // Save to session Session["captcha"] = s.ToLower(); /* if (context.Session["Captcha"].ToString() != null) { strCaptcha = context.Session["Captcha"].ToString(); }*/ imgCaptcha.ImageUrl = "~/Handlers/CaptchaHandler.ashx?c=" + s; }
public void LeftOperand_ShouldBe2_WhenInputIs2() { Captcha captcha = new Captcha(2, 2, 1, 1); Assert.AreEqual("2", captcha.GetLeftOperand()); }
public void Get_ShouldBeTWOMultiply2_WhenPatternIs1_LeftOperandIs2_OperatorIs2_RightOperandIs2() { var captcha = new Captcha(1, 2, 2, 2); Assert.AreEqual("TWO * 2", captcha.Get()); }
public void Get_ShouldBeOnePlus1_WhenPatternIs1_LeftOperandIs1_OperatorIs1_RightOperandIs1() { var captcha = new Captcha(1, 1, 1, 1); Assert.AreEqual("ONE + 1", captcha.Get()); }
public void Get_ShouldReturnOnePlus1_WhenInput1111() { Captcha captcha = new Captcha(1, 1, 1, 1); var result = captcha.Get(); Assert.AreEqual("One + 1", result); }
public void Operator_ShouldBeMultiply_WhenInputIs2() { Captcha captcha = new Captcha(pattern: 2, leftOperand: 1, operatorValue: 2, rightOperand: 1); Assert.AreEqual("*", captcha.GetOperator()); }
public void LeftOperand_ShouldBeONE_WhenPatternIs1AndLeftOperandIs1() { Captcha captcha = new Captcha(pattern: 1, leftOperand: 1, operatorValue: 2, rightOperand: 1); Assert.AreEqual("ONE", captcha.GetLeftOperand()); }
public void RightOperand_ShouldBeTWO_WhenInputIs2() { Captcha captcha = new Captcha(2, 1, 1, 2); Assert.AreEqual("TWO", captcha.GetRightOperand()); }