public void CommandTest() { Run("UITests.Microsoft_UI_Xaml_Controls.SplitButtonTests.SplitButtonPage"); var splitButton = new QueryEx(q => q.All().Marked("CommandSplitButton")); var canExecuteCheckBox = new QueryEx(q => q.All().Marked("CanExecuteCheckBox")); var executeCountTextBlock = new QueryEx(q => q.All().Marked("ExecuteCountTextBlock")); Console.WriteLine("Assert that the control starts out enabled"); Assert.IsTrue("true".Equals(canExecuteCheckBox.GetDependencyPropertyValue("IsChecked").ToString(), StringComparison.InvariantCultureIgnoreCase)); Assert.IsTrue("true".Equals(splitButton.GetDependencyPropertyValue("IsEnabled").ToString(), StringComparison.InvariantCultureIgnoreCase)); Assert.AreEqual("0", executeCountTextBlock.GetText()); Console.WriteLine("Click primary button to execute command"); TapPrimaryButton(splitButton); Assert.AreEqual("1", executeCountTextBlock.GetText()); Console.WriteLine("Assert that setting CanExecute to false disables the primary button"); canExecuteCheckBox.FastTap(); //Wait.ForIdle(); TapPrimaryButton(splitButton); Assert.AreEqual("1", executeCountTextBlock.GetText()); }
private void ChangeTextAndAssertBeforeAfter(QueryEx textbox, string initialTextAlignment, string finalText, string finalTextAlignment) { // Focus textbox textbox.FastTap(); // Assert initial state Assert.AreEqual(initialTextAlignment, textbox.GetDependencyPropertyValue("TextAlignment")?.ToString()); // Update text content _app.ClearText(); _app.EnterText(finalText); // Assert final state Assert.AreEqual(finalTextAlignment, textbox.GetDependencyPropertyValue("TextAlignment")?.ToString()); }