public void MoveSelectedWord_EmptyString() { using (TextBox txt = new TextBox()) { Assert.IsFalse(txt.MoveSelectedWord(true)); Assert.AreEqual(String.Empty, txt.Text); Assert.IsFalse(txt.MoveSelectedWord(false)); Assert.AreEqual(String.Empty, txt.Text); } }
public void MoveSelectedWord_OneWord() { const string initial = "dog"; using (TextBox txt = new TextBox()) { txt.Text = initial; Assert.IsFalse(txt.MoveSelectedWord(true)); Assert.AreEqual(initial, txt.Text); Assert.IsFalse(txt.MoveSelectedWord(false)); Assert.AreEqual(initial, txt.Text); txt.SelectionStart = 3; Assert.IsFalse(txt.MoveSelectedWord(true)); Assert.AreEqual(initial, txt.Text); Assert.IsFalse(txt.MoveSelectedWord(false)); Assert.AreEqual(initial, txt.Text); txt.SelectionStart = 0; txt.SelectionLength = 3; Assert.IsFalse(txt.MoveSelectedWord(true)); Assert.AreEqual(initial, txt.Text); Assert.IsFalse(txt.MoveSelectedWord(false)); Assert.AreEqual(initial, txt.Text); } }
public void MoveSelectedWord_AdvanceInitialPunc() { // 0 1 2 3 4 // 0123456789012345678901234567890123456789012 const string initial = "\u00BFQue\u0301 le dijo Potifar a Jose\u0301?"; using (TextBox txt = new TextBox()) { txt.Text = initial; txt.SelectionStart = 0; txt.SelectionLength = 1; Assert.IsTrue(txt.MoveSelectedWord(true)); // 0 1 2 3 4 // 0123456789012345678901234567890123456789012 Assert.AreEqual("Que\u0301 \u00BFle dijo Potifar a Jose\u0301?", txt.Text); } }
public void MoveSelectedWord_AdvanceWordFollowingSentenceInitialPunc() { // 0 1 2 3 4 // 0123456789012345678901234567890123456789012 const string initial = "\u00BFnoto\u0301 Que\u0301 Potifar Jose\u0301 Potifar familia?"; using (TextBox txt = new TextBox()) { txt.Text = initial; txt.SelectionStart = 1; txt.SelectionLength = 5; Assert.IsTrue(txt.MoveSelectedWord(true)); Assert.AreEqual("\u00BFQue\u0301 noto\u0301 Potifar Jose\u0301 Potifar familia?", txt.Text); } }
public void MoveSelectedWord_OneWord_MiddleOfWordSelected() { const string initial = "dog"; using (TextBox txt = new TextBox()) { txt.Text = initial; txt.SelectionStart = 1; txt.SelectionLength = 1; Assert.IsTrue(txt.MoveSelectedWord(true)); Assert.AreEqual("dgo", txt.Text); Assert.AreEqual(2, txt.SelectionStart); Assert.AreEqual(1, txt.SelectionLength); txt.Text = initial; txt.SelectionStart = 1; txt.SelectionLength = 1; Assert.IsTrue(txt.MoveSelectedWord(false)); Assert.AreEqual("odg", txt.Text); Assert.AreEqual(0, txt.SelectionStart); Assert.AreEqual(1, txt.SelectionLength); } }
public void MoveSelectedWord_MoveSelectedWordBackwardPastComma() { // 0 1 2 3 4 // 0123456789012345678901234567890123456789012 const string initial = "The quick brown fox ate the poor, wimpy dog."; using (TextBox txt = new TextBox()) { txt.Text = initial; txt.SelectionStart = 34; txt.SelectionLength = 5; Assert.IsTrue(txt.MoveSelectedWord(false)); // 0 1 2 3 4 // 0123456789012345678901234567890123456789012 Assert.AreEqual("The quick brown fox ate the wimpy poor, dog.", txt.Text); Assert.AreEqual(28, txt.SelectionStart); Assert.AreEqual(6, txt.SelectionLength); } }
public void MoveSelectedWord_IpInWordBeforeComma() { // 0 1 2 3 4 // 0123456789012345678901234567890123456789012 const string initial = "The quick brown fox ate the poor, wimpy dog."; using (TextBox txt = new TextBox()) { txt.Text = initial; txt.SelectionStart = 29; txt.SelectionLength = 0; Assert.IsTrue(txt.MoveSelectedWord(true)); // 0 1 2 3 4 // 0123456789012345678901234567890123456789012 Assert.AreEqual("The quick brown fox ate the wimpy poor, dog.", txt.Text); Assert.AreEqual(33, txt.SelectionStart); Assert.AreEqual(6, txt.SelectionLength); txt.Text = initial; txt.SelectionStart = 29; txt.SelectionLength = 0; Assert.IsTrue(txt.MoveSelectedWord(false)); // 0 1 2 3 4 // 0123456789012345678901234567890123456789012 Assert.AreEqual("The quick brown fox ate poor, the wimpy dog.", txt.Text); Assert.AreEqual(24, txt.SelectionStart); Assert.AreEqual(6, txt.SelectionLength); } }
public void MoveSelectedWord_Normal_SingleWordSelected_BackwardToStart_NoPunctuation() { // 0 1 2 3 4 // 0123456789012345678901234567890123456789012 const string initial = "The quick brown fox ate the poor wimpy dog"; using (TextBox txt = new TextBox()) { // Start with second-to-last word txt.Text = initial; int prevStart = txt.SelectionStart = 33; txt.SelectionLength = 5; int steps = 0; while (txt.MoveSelectedWord(false)) { Assert.IsTrue(prevStart > txt.SelectionStart); Assert.AreEqual(6, txt.SelectionLength); prevStart = txt.SelectionStart; steps++; } Assert.AreEqual(7, steps); Assert.AreEqual("wimpy The quick brown fox ate the poor dog", txt.Text); Assert.AreEqual(0, txt.SelectionStart); Assert.AreEqual(6, txt.SelectionLength); // Start with last word txt.Text = initial; prevStart = txt.SelectionStart = 39; txt.SelectionLength = 3; steps = 0; while (txt.MoveSelectedWord(false)) { Assert.IsTrue(prevStart > txt.SelectionStart); Assert.AreEqual(4, txt.SelectionLength); prevStart = txt.SelectionStart; steps++; } Assert.AreEqual(8, steps); // 0 1 2 3 4 // 0123456789012345678901234567890123456789012 Assert.AreEqual("dog The quick brown fox ate the poor wimpy", txt.Text); Assert.AreEqual(0, txt.SelectionStart); Assert.AreEqual(4, txt.SelectionLength); } }
public void MoveSelectedWord_Normal_SingleWordSelected_BackwardToStart_InitialPunctuation() { // 0 1 2 3 4 // 01234567890123456789012345678901234567890123456 // ?Por que' comio' el zorro al pobre perro debil? const string initial = "\u00BFPor que\u0301 comio\u0301 el zorro al pobre perro debil?"; using (TextBox txt = new TextBox()) { txt.Text = initial; int prevStart = txt.SelectionStart = 41; txt.SelectionLength = 5; int steps = 0; while (txt.MoveSelectedWord(false)) { Assert.IsTrue(prevStart > txt.SelectionStart); Assert.AreEqual(6, txt.SelectionLength); prevStart = txt.SelectionStart; steps++; } Assert.AreEqual(8, steps); Assert.AreEqual("\u00BFdebil Por que\u0301 comio\u0301 el zorro al pobre perro?", txt.Text); Assert.AreEqual(1, txt.SelectionStart); Assert.AreEqual(6, txt.SelectionLength); } }
public void MoveSelectedWord_Normal_SingleWordSelected_ForwardToEnd_NoPunctuation() { const string initial = "The quick brown fox ate the poor wimpy dog"; using (TextBox txt = new TextBox()) { // Start with second word txt.Text = initial; int prevStart = txt.SelectionStart = 4; txt.SelectionLength = 5; int steps = 0; while (txt.MoveSelectedWord(true)) { Assert.IsTrue(prevStart < txt.SelectionStart); Assert.AreEqual(6, txt.SelectionLength); prevStart = txt.SelectionStart; steps++; } Assert.AreEqual(7, steps); // 0 1 2 3 4 // 0123456789012345678901234567890123456789012 Assert.AreEqual("The brown fox ate the poor wimpy dog quick", txt.Text); Assert.AreEqual(36, txt.SelectionStart); Assert.AreEqual(6, txt.SelectionLength); // Start with first word txt.Text = initial; prevStart = txt.SelectionStart = 0; txt.SelectionLength = 3; steps = 0; while (txt.MoveSelectedWord(true)) { Assert.IsTrue(prevStart < txt.SelectionStart); Assert.AreEqual(4, txt.SelectionLength); prevStart = txt.SelectionStart; steps++; } Assert.AreEqual(8, steps); // 0 1 2 3 4 // 0123456789012345678901234567890123456789012 Assert.AreEqual("quick brown fox ate the poor wimpy dog The", txt.Text); Assert.AreEqual(38, txt.SelectionStart); Assert.AreEqual(4, txt.SelectionLength); } }
public void MoveSelectedWord_Normal_SingleWordSelected_ForwardToEnd_FinalPunctuation() { const string initial = "The quick brown fox ate\u0301 the poor wimpy dog."; using (TextBox txt = new TextBox()) { txt.Text = initial; int prevStart = txt.SelectionStart = 4; txt.SelectionLength = 5; int steps = 0; while (txt.MoveSelectedWord(true)) { Assert.IsTrue(prevStart < txt.SelectionStart); Assert.AreEqual(6, txt.SelectionLength); prevStart = txt.SelectionStart; steps++; } Assert.AreEqual(7, steps); // 0 1 2 3 4 // 01234567890123456789012345678901234567890123 // The brown fox ate' the poor wimpy dog quick. Assert.AreEqual("The brown fox ate\u0301 the poor wimpy dog quick.", txt.Text); Assert.AreEqual(37, txt.SelectionStart); Assert.AreEqual(6, txt.SelectionLength); } }
public void MoveSelectedWord_Normal_SingleWordSelected_BackwardThenForward() { const string initial = "The quick brown fox ate the poor wimpy dog."; using (TextBox txt = new TextBox()) { txt.Text = initial; txt.SelectionStart = 10; txt.SelectionLength = 5; Assert.IsTrue(txt.MoveSelectedWord(false)); Assert.AreEqual("The brown quick fox ate the poor wimpy dog.", txt.Text); Assert.AreEqual(4, txt.SelectionStart); Assert.AreEqual(6, txt.SelectionLength); Assert.IsTrue(txt.MoveSelectedWord(true)); Assert.AreEqual(initial, txt.Text); Assert.AreEqual(10, txt.SelectionStart); Assert.AreEqual(6, txt.SelectionLength); } }
public void MoveSelectedWord_OneWord_SpaceAfter_StartOfWordSelected() { const string initial = "dog "; using (TextBox txt = new TextBox()) { txt.Text = initial; txt.SelectionStart = 0; txt.SelectionLength = 2; Assert.IsTrue(txt.MoveSelectedWord(true)); Assert.AreEqual("g do", txt.Text); Assert.AreEqual(2, txt.SelectionStart); Assert.AreEqual(2, txt.SelectionLength); txt.Text = initial; txt.SelectionStart = 0; txt.SelectionLength = 2; Assert.IsFalse(txt.MoveSelectedWord(false)); Assert.AreEqual(initial, txt.Text); } }
public void MoveSelectedWord_OneWord_SpaceAfter_IPBeforeSpace() { const string initial = "dog "; using (TextBox txt = new TextBox()) { txt.Text = initial; txt.SelectionStart = 3; txt.SelectionLength = 0; Assert.IsTrue(txt.MoveSelectedWord(true)); Assert.AreEqual(" dog", txt.Text); Assert.AreEqual(1, txt.SelectionStart); Assert.AreEqual(3, txt.SelectionLength); txt.Text = initial; txt.SelectionStart = 3; txt.SelectionLength = 0; Assert.IsFalse(txt.MoveSelectedWord(false)); Assert.AreEqual(initial, txt.Text); } }