void translate_Click(object sender, EventArgs e) { try { _spelling.ReplaceWord(Google.TranslateText(_spelling.CurrentWord, "", new CultureInfo(Settings.Dictionary.Replace('_', '-')).TwoLetterISOLanguageName)); } catch (Exception ex) { MessageBox.Show(this, ex.ToString()); } }
public void NoText() { Spelling _SpellChecker = NewSpellChecker(); Assert.AreEqual(string.Empty, _SpellChecker.CurrentWord, "Incorrect Current Word"); _SpellChecker.WordIndex = 1; Assert.AreEqual(0, _SpellChecker.WordIndex, "Incorrect Word Index"); Assert.AreEqual(0, _SpellChecker.WordCount, "Incorrect Word Count"); Assert.AreEqual(0, _SpellChecker.TextIndex, "Incorrect Text Index"); _SpellChecker.DeleteWord(); Assert.AreEqual(string.Empty, _SpellChecker.Text, "Incorrect Text"); _SpellChecker.IgnoreWord(); Assert.AreEqual(string.Empty, _SpellChecker.Text, "Incorrect Text"); _SpellChecker.ReplaceWord("Test"); Assert.AreEqual(string.Empty, _SpellChecker.Text, "Incorrect Text"); Assert.IsFalse(_SpellChecker.SpellCheck(), "Spell Check not false"); _SpellChecker.Suggest(); Assert.AreEqual(0, _SpellChecker.Suggestions.Count, "Generated Suggestions with no text"); }
private void SuggestionToolStripItemClick(object sender, EventArgs e) { _spelling.ReplaceWord(((ToolStripItem)sender).Text); CheckSpelling(); }
public void ReplaceWord() { Spelling _SpellChecker = NewSpellChecker(); _SpellChecker.Text = "ths is an errr tst"; _SpellChecker.SpellCheck(); Assert.AreEqual(0, _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.AreEqual("ths", _SpellChecker.CurrentWord, "Incorrect CurrentWord"); _SpellChecker.ReplacementWord = "this"; _SpellChecker.ReplaceWord(); Assert.AreEqual("this is an errr tst", _SpellChecker.Text, "Incorrect Text"); //replace with empty string _SpellChecker.SpellCheck(); Assert.AreEqual(3, _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.AreEqual("errr", _SpellChecker.CurrentWord, "Incorrect CurrentWord"); _SpellChecker.ReplaceWord(""); Assert.AreEqual("this is an tst", _SpellChecker.Text, "Incorrect Text"); _SpellChecker.Text = "Becuase people are realy bad spelers, \r\nths produc was desinged to prevent spelling errors in a text area like ths."; _SpellChecker.SpellCheck(); Assert.AreEqual(0, _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.AreEqual("Becuase", _SpellChecker.CurrentWord, "Incorrect CurrentWord"); _SpellChecker.ReplaceWord("because"); Assert.AreEqual("Because people are realy bad spelers, \r\nths produc was desinged to prevent spelling errors in a text area like ths.", _SpellChecker.Text, "Incorrect Text"); _SpellChecker.SpellCheck(); Assert.AreEqual(3, _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.AreEqual("realy", _SpellChecker.CurrentWord, "Incorrect CurrentWord"); _SpellChecker.ReplaceWord("really"); Assert.AreEqual("Because people are really bad spelers, \r\nths produc was desinged to prevent spelling errors in a text area like ths.", _SpellChecker.Text, "Incorrect Text"); _SpellChecker.SpellCheck(); Assert.AreEqual(5, _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.AreEqual("spelers", _SpellChecker.CurrentWord, "Incorrect CurrentWord"); _SpellChecker.ReplaceWord("spellers"); Assert.AreEqual("Because people are really bad spellers, \r\nths produc was desinged to prevent spelling errors in a text area like ths.", _SpellChecker.Text, "Incorrect Text"); _SpellChecker.SpellCheck(); Assert.AreEqual(6, _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.AreEqual("ths", _SpellChecker.CurrentWord, "Incorrect CurrentWord"); _SpellChecker.ReplaceWord("this"); Assert.AreEqual("Because people are really bad spellers, \r\nthis produc was desinged to prevent spelling errors in a text area like ths.", _SpellChecker.Text, "Incorrect Text"); _SpellChecker.SpellCheck(); Assert.AreEqual(7, _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.AreEqual("produc", _SpellChecker.CurrentWord, "Incorrect CurrentWord"); _SpellChecker.ReplaceWord("product"); Assert.AreEqual("Because people are really bad spellers, \r\nthis product was desinged to prevent spelling errors in a text area like ths.", _SpellChecker.Text, "Incorrect Text"); _SpellChecker.SpellCheck(); Assert.AreEqual(9, _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.AreEqual("desinged", _SpellChecker.CurrentWord, "Incorrect CurrentWord"); _SpellChecker.ReplaceWord("designed"); Assert.AreEqual("Because people are really bad spellers, \r\nthis product was designed to prevent spelling errors in a text area like ths.", _SpellChecker.Text, "Incorrect Text"); _SpellChecker.SpellCheck(); Assert.AreEqual(19, _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.AreEqual("ths", _SpellChecker.CurrentWord, "Incorrect CurrentWord"); _SpellChecker.ReplaceWord("this"); Assert.AreEqual("Because people are really bad spellers, \r\nthis product was designed to prevent spelling errors in a text area like this.", _SpellChecker.Text, "Incorrect Text"); }
protected void RemoveButton_Click(object sender, EventArgs e) { SpellChecker.ReplaceWord(String.Empty); CurrentText.Value = SpellChecker.Text; SpellChecker.SpellCheck(); }
public void ReplaceWord() { Spelling _SpellChecker = NewSpellChecker(); _SpellChecker.Text = "ths is an errr tst"; _SpellChecker.SpellCheck(); Assert.True(0 == _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.True("ths" == _SpellChecker.CurrentWord, "Incorrect CurrentWord"); _SpellChecker.ReplacementWord = "this"; _SpellChecker.ReplaceWord(); Assert.True("this is an errr tst" == _SpellChecker.Text, "Incorrect Text"); //replace with empty string _SpellChecker.SpellCheck(); Assert.True(3 == _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.True("errr" == _SpellChecker.CurrentWord, "Incorrect CurrentWord"); _SpellChecker.ReplaceWord(""); Assert.True("this is an tst" == _SpellChecker.Text, "Incorrect Text"); _SpellChecker.Text = "Becuase people are realy bad spelers, \r\nths produc was desinged to prevent spelling errors in a text area like ths."; _SpellChecker.SpellCheck(); Assert.True(0 == _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.True("Becuase" == _SpellChecker.CurrentWord, "Incorrect CurrentWord"); _SpellChecker.ReplaceWord("because"); Assert.True("Because people are realy bad spelers, \r\nths produc was desinged to prevent spelling errors in a text area like ths." == _SpellChecker.Text, "Incorrect Text"); //_SpellChecker.SpellCheck(); //Assert.True(3 == _SpellChecker.WordIndex, "Incorrect WordOffset"); //Assert.True("realy" == _SpellChecker.CurrentWord, "Incorrect CurrentWord"); //_SpellChecker.ReplaceWord("really"); //Assert.True("Because people are really bad spelers, \r\nths produc was desinged to prevent spelling errors in a text area like ths." == _SpellChecker.Text, "Incorrect Text"); //_SpellChecker.SpellCheck(); //Assert.True(5 == _SpellChecker.WordIndex, "Incorrect WordOffset"); //Assert.True("spelers" == _SpellChecker.CurrentWord, "Incorrect CurrentWord"); //_SpellChecker.ReplaceWord("spellers"); //Assert.True("Because people are really bad spellers, \r\nths produc was desinged to prevent spelling errors in a text area like ths." == _SpellChecker.Text, "Incorrect Text"); //_SpellChecker.SpellCheck(); //Assert.True(6 == _SpellChecker.WordIndex, "Incorrect WordOffset"); //Assert.True("ths" == _SpellChecker.CurrentWord, "Incorrect CurrentWord"); //_SpellChecker.ReplaceWord("this"); //Assert.True("Because people are really bad spellers, \r\nthis produc was desinged to prevent spelling errors in a text area like ths." == _SpellChecker.Text, "Incorrect Text"); //_SpellChecker.SpellCheck(); //Assert.True(7 == _SpellChecker.WordIndex, "Incorrect WordOffset"); //Assert.True("produc" == _SpellChecker.CurrentWord, "Incorrect CurrentWord"); //_SpellChecker.ReplaceWord("product"); //Assert.True("Because people are really bad spellers, \r\nthis product was desinged to prevent spelling errors in a text area like ths." == _SpellChecker.Text, "Incorrect Text"); //_SpellChecker.SpellCheck(); //Assert.True(9 == _SpellChecker.WordIndex, "Incorrect WordOffset"); //Assert.True("desinged" == _SpellChecker.CurrentWord, "Incorrect CurrentWord"); //_SpellChecker.ReplaceWord("designed"); //Assert.True("Because people are really bad spellers, \r\nthis product was designed to prevent spelling errors in a text area like ths." == _SpellChecker.Text, "Incorrect Text"); //_SpellChecker.SpellCheck(); //Assert.True(19 == _SpellChecker.WordIndex, "Incorrect WordOffset"); //Assert.True("ths" == _SpellChecker.CurrentWord, "Incorrect CurrentWord"); //_SpellChecker.ReplaceWord("this"); //Assert.True("Because people are really bad spellers, \r\nthis product was designed to prevent spelling errors in a text area like this." == _SpellChecker.Text, "Incorrect Text"); }
public void TestEvents() { Spelling _SpellChecker = NewSpellChecker(); _SpellChecker.Text = "ths is is a tst."; ResetEvents(); _SpellChecker.SpellCheck(); //spelling check Assert.AreEqual(0, _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.AreEqual("ths", _SpellChecker.CurrentWord, "Incorrect CurrentWord"); // event check Assert.AreEqual(EventNames.MisspelledWord, _lastEvent, "Incorrect Event"); Assert.IsNotNull(_lastSpellingEvent, "Event not fired"); Assert.AreEqual(0, _lastSpellingEvent.WordIndex, "Incorrect Event Word Index"); Assert.AreEqual(0, _lastSpellingEvent.TextIndex, "Incorrect Event Text Index"); Assert.AreEqual("ths", _lastSpellingEvent.Word, "Incorrect Event Word"); ResetEvents(); _SpellChecker.ReplaceWord("this"); //spelling check Assert.AreEqual("this is is a tst.", _SpellChecker.Text, "Incorrect Text"); // event check Assert.AreEqual(EventNames.ReplacedWord, _lastEvent, "Incorrect Event"); Assert.IsNotNull(_lastReplaceEvent, "Null Event object fired"); Assert.AreEqual(0, _lastReplaceEvent.WordIndex, "Incorrect Event Word Index"); Assert.AreEqual(0, _lastReplaceEvent.TextIndex, "Incorrect Event Text Index"); Assert.AreEqual("ths", _lastReplaceEvent.Word, "Incorrect Event Word"); Assert.AreEqual("this", _lastReplaceEvent.ReplacementWord, "Incorrect Event Replacement Word"); ResetEvents(); _SpellChecker.SpellCheck(); //spelling check Assert.AreEqual(2, _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.AreEqual("is", _SpellChecker.CurrentWord, "Incorrect CurrentWord"); // event check Assert.AreEqual(EventNames.DoubledWord, _lastEvent, "Incorrect Event"); Assert.IsNotNull(_lastSpellingEvent, "Null Event object fired"); Assert.AreEqual(2, _lastSpellingEvent.WordIndex, "Incorrect Event Word Index"); Assert.AreEqual(8, _lastSpellingEvent.TextIndex, "Incorrect Event Text Index"); Assert.AreEqual("is", _lastSpellingEvent.Word, "Incorrect Event Word"); ResetEvents(); _SpellChecker.DeleteWord(); //spelling check Assert.AreEqual("this is a tst.", _SpellChecker.Text, "Incorrect Text"); // event check Assert.AreEqual(EventNames.DeletedWord, _lastEvent, "Incorrect Event"); Assert.IsNotNull(_lastSpellingEvent, "Null Event object fired"); Assert.AreEqual(2, _lastSpellingEvent.WordIndex, "Incorrect Event Word Index"); Assert.AreEqual(8, _lastSpellingEvent.TextIndex, "Incorrect Event Text Index"); Assert.AreEqual("is ", _lastSpellingEvent.Word, "Incorrect Event Word"); ResetEvents(); _SpellChecker.SpellCheck(); //spelling check Assert.AreEqual(3, _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.AreEqual("tst", _SpellChecker.CurrentWord, "Incorrect CurrentWord"); // event check Assert.AreEqual(EventNames.MisspelledWord, _lastEvent, "Incorrect Event"); Assert.IsNotNull(_lastSpellingEvent, "Null Event object fired"); Assert.AreEqual(3, _lastSpellingEvent.WordIndex, "Incorrect Event Word Index"); Assert.AreEqual(10, _lastSpellingEvent.TextIndex, "Incorrect Event Text Index"); Assert.AreEqual("tst", _lastSpellingEvent.Word, "Incorrect Event Word"); ResetEvents(); _SpellChecker.IgnoreWord(); //spelling check Assert.AreEqual("this is a tst.", _SpellChecker.Text, "Incorrect Text"); // event check Assert.AreEqual(EventNames.IgnoredWord, _lastEvent, "Incorrect Event"); Assert.IsNotNull(_lastSpellingEvent, "Null Event object fired"); Assert.AreEqual(3, _lastSpellingEvent.WordIndex, "Incorrect Event Word Index"); Assert.AreEqual(10, _lastSpellingEvent.TextIndex, "Incorrect Event Text Index"); Assert.AreEqual("tst", _lastSpellingEvent.Word, "Incorrect Event Word"); ResetEvents(); _SpellChecker.SpellCheck(); // event check Assert.AreEqual(EventNames.EndOfText, _lastEvent, "Incorrect Event"); }
public void TestEvents() { Spelling _SpellChecker = NewSpellChecker(); _SpellChecker.Text = "ths is is a tst."; ResetEvents(); _SpellChecker.SpellCheck(); //spelling check Assert.True(0 == _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.True("ths" == _SpellChecker.CurrentWord, "Incorrect CurrentWord"); // event check Assert.True(EventNames.MisspelledWord == _lastEvent, "Incorrect Event"); Assert.NotNull(_lastSpellingEvent); //, "Event not fired"); Assert.True(0 == _lastSpellingEvent.WordIndex, "Incorrect Event Word Index"); Assert.True(0 == _lastSpellingEvent.TextIndex, "Incorrect Event Text Index"); Assert.True("ths" == _lastSpellingEvent.Word, "Incorrect Event Word"); ResetEvents(); _SpellChecker.ReplaceWord("this"); //spelling check Assert.True("this is is a tst." == _SpellChecker.Text, "Incorrect Text"); // event check Assert.True(EventNames.ReplacedWord == _lastEvent, "Incorrect Event"); Assert.NotNull(_lastReplaceEvent); //, "Null Event object fired"); Assert.True(0 == _lastReplaceEvent.WordIndex, "Incorrect Event Word Index"); Assert.True(0 == _lastReplaceEvent.TextIndex, "Incorrect Event Text Index"); Assert.True("ths" == _lastReplaceEvent.Word, "Incorrect Event Word"); Assert.True("this" == _lastReplaceEvent.ReplacementWord, "Incorrect Event Replacement Word"); ResetEvents(); _SpellChecker.SpellCheck(); //spelling check Assert.True(2 == _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.True("is" == _SpellChecker.CurrentWord, "Incorrect CurrentWord"); // event check Assert.True(EventNames.DoubledWord == _lastEvent, "Incorrect Event"); Assert.NotNull(_lastSpellingEvent); //, "Null Event object fired"); Assert.True(2 == _lastSpellingEvent.WordIndex, "Incorrect Event Word Index"); Assert.True(8 == _lastSpellingEvent.TextIndex, "Incorrect Event Text Index"); Assert.True("is" == _lastSpellingEvent.Word, "Incorrect Event Word"); ResetEvents(); _SpellChecker.DeleteWord(); //spelling check Assert.True("this is a tst." == _SpellChecker.Text, "Incorrect Text"); // event check Assert.True(EventNames.DeletedWord == _lastEvent, "Incorrect Event"); Assert.NotNull(_lastSpellingEvent); //, "Null Event object fired"); Assert.True(2 == _lastSpellingEvent.WordIndex, "Incorrect Event Word Index"); Assert.True(8 == _lastSpellingEvent.TextIndex, "Incorrect Event Text Index"); Assert.True("is " == _lastSpellingEvent.Word, "Incorrect Event Word"); ResetEvents(); _SpellChecker.SpellCheck(); //spelling check Assert.True(3 == _SpellChecker.WordIndex, "Incorrect WordOffset"); Assert.True("tst" == _SpellChecker.CurrentWord, "Incorrect CurrentWord"); // event check Assert.True(EventNames.MisspelledWord == _lastEvent, "Incorrect Event"); Assert.NotNull(_lastSpellingEvent); //, "Null Event object fired"); Assert.True(3 == _lastSpellingEvent.WordIndex, "Incorrect Event Word Index"); Assert.True(10 == _lastSpellingEvent.TextIndex, "Incorrect Event Text Index"); Assert.True("tst" == _lastSpellingEvent.Word, "Incorrect Event Word"); ResetEvents(); _SpellChecker.IgnoreWord(); //spelling check Assert.True("this is a tst." == _SpellChecker.Text, "Incorrect Text"); // event check Assert.True(EventNames.IgnoredWord == _lastEvent, "Incorrect Event"); Assert.NotNull(_lastSpellingEvent); //, "Null Event object fired"); Assert.True(3 == _lastSpellingEvent.WordIndex, "Incorrect Event Word Index"); Assert.True(10 == _lastSpellingEvent.TextIndex, "Incorrect Event Text Index"); Assert.True("tst" == _lastSpellingEvent.Word, "Incorrect Event Word"); ResetEvents(); _SpellChecker.SpellCheck(); // event check Assert.True(EventNames.EndOfText == _lastEvent, "Incorrect Event"); }