public void AddBaddBeforeStarSpellling() { MakeEmptyFooDictionary(); var dict = SpellingHelper.GetSpellChecker("foo"); dict.SetStatus("spellling", false); dict.SetStatus("badd", true); SpellingHelper.ClearAllDictionaries(); dict = SpellingHelper.GetSpellChecker("foo"); Assert.That(dict.Check("spellling"), Is.False); Assert.That(dict.Check("badd"), Is.True); }
public void BasicSpellingStatus() { var dictId = MakeEmptyFooDictionary(); var dict = SpellingHelper.GetSpellChecker(dictId); Assert.That(dict, Is.Not.Null); Assert.That(dict.Check("nonsense"), Is.False); Assert.That(dict.Check("big"), Is.False); dict.SetStatus("big", true); Assert.That(dict.Check("big"), Is.True); // By default Hunspell fails this test; setting "big" to correct makes "Big" correct too. // We override this behavior (in a rather tricky way) for vernacular dictionaries. Assert.That(dict.Check("Big"), Is.False); dict.SetStatus("Big", false); Assert.That(dict.Check("Big"), Is.False); Assert.That(dict.Check("big"), Is.True); // If we set the upper case version only, that is considered correct, but the LC version is not. Assert.That(dict.Check("Bother"), Is.False); dict.SetStatus("Bother", true); Assert.That(dict.Check("Bother"), Is.True); Assert.That(dict.Check("bother"), Is.False); // Subsequently explicitly setting the LC version to false is not a problem. dict.SetStatus("bother", false); Assert.That(dict.Check("Bother"), Is.True); Assert.That(dict.Check("bother"), Is.False); // Now if we set the UC version false, both are. dict.SetStatus("Bother", false); Assert.That(dict.Check("Bother"), Is.False); Assert.That(dict.Check("bother"), Is.False); // Now both are explicitly false. Set the LC one to true. dict.SetStatus("bother", true); Assert.That(dict.Check("Bother"), Is.False); Assert.That(dict.Check("bother"), Is.True); // Now make the LC one false again. dict.SetStatus("bother", false); Assert.That(dict.Check("Bother"), Is.False); Assert.That(dict.Check("bother"), Is.False); // Now make the UC one true again. dict.SetStatus("Bother", true); Assert.That(dict.Check("Bother"), Is.True); Assert.That(dict.Check("bother"), Is.False); // There is a special case in the code when the new word is alphabetically after any we already added. dict.SetStatus("world", true); Assert.That(dict.Check("world"), Is.True); // Check normalization dict.SetStatus("w\x00f4rld", true); // o with cicrumflex (composed) Assert.That(dict.Check("w\x00f4rld"), Is.True); Assert.That(dict.Check("wo\x0302rld"), Is.True); // decomposed form. dict.SetStatus("bo\x0302lt", true); // set decomposed Assert.That(dict.Check("bo\x0302lt"), Is.True); Assert.That(dict.Check("b\x00f4lt"), Is.True); // composed form. // Check that results were persisted. SpellingHelper.ClearAllDictionaries(); dict = SpellingHelper.GetSpellChecker(dictId); Assert.That(dict.Check("Bother"), Is.True); Assert.That(dict.Check("world"), Is.True); }