public void Test_SettingToFalse_ShouldUnsubscribe() { // Arrange. string text = "this is some text"; textBox.Text = text; var behavior = new AutoSelectOnFocusBehavior(); behavior.Attach(textBox); behavior.Detach(); // Act. textBox.RaiseGotFocus(); // Assert. Assert.Equal(0, textBox.SelectionLength); Assert.Equal(string.Empty, textBox.SelectedText); }
public void Test_GotKeyboardFocus_ShouldAutoSelect() { // Arrange. string text = "this is some text"; textBox.Text = text; var behavior = new AutoSelectOnFocusBehavior(); behavior.Attach(textBox); // Preconditions. Assert.Equal(0, textBox.SelectionLength); Assert.Equal(string.Empty, textBox.SelectedText); // Act. textBox.RaiseGotFocus(); // Assert. Assert.Equal(text.Length, textBox.SelectionLength); Assert.Equal(text, textBox.SelectedText); }