/// <summary>
        /// Evaluate spelling
        /// </summary>
        /// <returns>
        /// The result of the evaluation.
        /// </returns>
        protected override ValidatorResult Evaluate()
        {
            string controlValidationValue = this.ControlValidationValue;
              if (string.IsNullOrEmpty(controlValidationValue))
              {
            return ValidatorResult.Valid;
              }

              ItemUri itemUri = this.ItemUri;
              if (itemUri == null)
              {
            return ValidatorResult.Valid;
              }

              CultureInfo cultureInfo = itemUri.Language.CultureInfo;
              if (cultureInfo.IsNeutralCulture)
              {
            cultureInfo = Language.CreateSpecificCulture(cultureInfo.Name);
              }

              var checker = new SpellChecker(FileUtil.MapPath(FileUtilMapPath))
              {
            Text = controlValidationValue,
            DictionaryLanguage = cultureInfo.Name
              };
              if (checker.CheckText().Count <= 2)
              {
            return ValidatorResult.Valid;
              }

              this.Text = string.Format("The field \"{0}\" contains more than two spelling errors.", this.GetFieldDisplayName());

              return this.GetFailedResult(ValidatorResult.Error);
        }
Exemplo n.º 2
0
 public void NoWhiteSpacesAtTextEnds()
 {
     Assert.That(SpellChecker.CheckText("one!\n  two-20\t'three apples , i yesh", new string[] { "apples", "too", "tree", "ys", "yeah", "y", "I" }), Is.EqualTo("{one?}!\n  too-20\t'tree apples , I {ys yeah}"));
 }
Exemplo n.º 3
0
 public void OneCorrectWordString()
 {
     Assert.That(SpellChecker.CheckText("a", new string[] { "abs", "ads", "b", "c", "a" }), Is.EqualTo("a"));
 }
Exemplo n.º 4
0
 public void WhiteSpaceAndOtherNonAlphabetMustBeIntact()
 {
     Assert.That(SpellChecker.CheckText("  one!\n  two-20\t'three apples , yesh'! ", new string[] { "apples", "too", "tree", "ys", "yeah", "y" }), Is.EqualTo("  {one?}!\n  too-20\t'tree apples , {ys yeah}'! "));
 }