示例#1
0
        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);
        }
示例#2
0
        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);
        }