public void Native_CaretPositionPatternSmokeTest()
{
CaretPositionPattern.Initialize();
var cps = (ICaretPositionPattern)_nAdvancedTextBoxElement.GetCurrentPattern(CaretPositionPattern.Pattern.Id);
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"
NSetTextAndSelection("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 = (IUIAutomationTextPattern)_nAdvancedTextBoxElement.GetCurrentPattern(TextPattern.Pattern.Id);
var selectionArray = text.GetSelection();
var selection = selectionArray.GetElement(0);
var selectedString = selection.GetText(-1);
Assert.AreEqual("bc", selectedString);
}