public void HandlerSetsIPCorrectlyWhenConvertFromCharAtEnd() { var keyEventArgs = new KeyEventArgs(Keys.Alt | Keys.X); using (var textBox = new TextBox()) { textBox.Text = "Some \u1234"; textBox.SelectionStart = 6; UnicodeCharacterEditingHelper.HandleKeyDown(textBox, keyEventArgs); Assert.That(textBox.Text, Is.EqualTo("Some 1234"), "The string should have been converted the character back to numbers"); Assert.That(textBox.SelectionStart, Is.EqualTo(9), "SelectionStart should have been moved forward"); } }
public void HandlerSetsIPCorrectlyWhenConvertToCharAtEnd() { var keyEventArgs = new KeyEventArgs(Keys.Alt | Keys.X); using (var textBox = new TextBox()) { textBox.Text = "Some 1234"; textBox.SelectionStart = 9; UnicodeCharacterEditingHelper.HandleKeyDown(textBox, keyEventArgs); Assert.That(textBox.Text, Is.EqualTo("Some \u1234"), "The string should have been converted to include the unicode character"); Assert.That(textBox.SelectionStart, Is.EqualTo(6), "SelectionStart should have been moved back"); } }
public void ConvertRLMAtEnd() { var keyEventArgs = new KeyEventArgs(Keys.Alt | Keys.X); using (var textBox = new TextBox()) { textBox.Text = "Blah 200F"; textBox.TextChanged += SpecialCharacterHandling.RevealInvisibleCharacters; textBox.SelectionStart = 9; UnicodeCharacterEditingHelper.HandleKeyDown(textBox, keyEventArgs); Assert.That(textBox.Text, Is.EqualTo("Blah∙[RLM]"), "The string should have been converted to include the character and then to visible characters"); Assert.That(textBox.SelectionStart, Is.EqualTo(10), "SelectionStart should be positioned based on 200F ultimately converting to [RLM]"); } }
public void ConvertRLM() { var keyEventArgs = new KeyEventArgs(Keys.Alt | Keys.X); using (var textBox = new TextBox()) { textBox.Text = "Some 200Ftext here"; textBox.TextChanged += SpecialCharacterHandling.RevealInvisibleCharacters; textBox.SelectionStart = 9; UnicodeCharacterEditingHelper.HandleKeyDown(textBox, keyEventArgs); Assert.That(textBox.Text, Is.EqualTo("Some∙[RLM]text∙here"), "The string should have been converted to 'Some∙[RLM]text∙here'"); Assert.That(textBox.SelectionStart, Is.EqualTo(10), "SelectionStart should be positioned based on 200F converting to [RLM]"); } }