public void ButtonsTest() { UITester.Dispatcher.Invoke(() => { bool stopped = false; testTutorialDialog.Manager.Stopped += (_, __) => stopped = true; var closeButton = testTutorialDialog.FindVisualDescendant <Button>(b => b.Name == "CloseButton"); closeButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, closeButton)); Assert.IsTrue(stopped); var checkbox = testTutorialDialog.FindVisualDescendant <CheckBox>(b => b.Name == "CheckBox"); var isChecked = checkbox.IsChecked; checkbox.IsChecked = true; checkbox.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, checkbox)); Assert.AreEqual(checkbox.IsChecked, testTutorialDialog.Manager.DontShowAgain); checkbox.IsChecked = isChecked; checkbox.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, checkbox)); Assert.AreEqual(checkbox.IsChecked, testTutorialDialog.Manager.DontShowAgain); // for code coverage var previousButton = testTutorialDialog.FindVisualDescendant <Button>(b => b.Name == "PreviousButton"); previousButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, previousButton)); var nextButton = testTutorialDialog.FindVisualDescendant <Button>(b => b.Name == "NextButton"); nextButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, nextButton)); }); }