UiaControlsTest.WpfAppTests.Wpf_CaretPositionPatternSmokeTest C# (CSharp) Method

Wpf_CaretPositionPatternSmokeTest() private method

private Wpf_CaretPositionPatternSmokeTest ( ) : void
return void
        public void Wpf_CaretPositionPatternSmokeTest()
        {
            CaretPositionPattern.Initialize();
            var cps = (ICaretPositionPattern)_wAdvancedTextBoxElement.GetCurrentPattern(CaretPositionPattern.Pattern);
            Assert.IsNotNull(cps);

            // sanity check: intial selection is none, there's no text after all
            Assert.AreEqual(0, cps.CurrentSelectionStart);
            Assert.AreEqual(0, cps.CurrentSelectionLength);

            // enter "abcd" and select central part of it - "bc"
            WSetTextAndSelection("abcd", 1, 2);
            Assert.AreEqual(1, cps.CurrentSelectionStart);
            Assert.AreEqual(2, cps.CurrentSelectionLength);

            // validate that selected text retrieved from TextPattern changed as expected
            var text = (TextPattern)_wAdvancedTextBoxElement.GetCurrentPattern(TextPattern.Pattern);
            var selectionArray = text.GetSelection();
            var selection = selectionArray[0];
            var selectedString = selection.GetText(-1);
            Assert.AreEqual("bc", selectedString);
        }