public void OnPreviewKeyDownTest() { UITester.Dispatcher.Invoke(() => { bool stopped = false; testTutorialDialog.Manager.Stopped += (_, __) => stopped = true; testTutorialDialog.RaiseEvent( new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Escape) { RoutedEvent = Keyboard.PreviewKeyDownEvent }); Assert.IsTrue(stopped); // for code coverage testTutorialDialog.RaiseEvent( new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Left) { RoutedEvent = Keyboard.PreviewKeyDownEvent }); testTutorialDialog.RaiseEvent( new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Right) { RoutedEvent = Keyboard.PreviewKeyDownEvent }); testTutorialDialog.RaiseEvent( new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Enter) { RoutedEvent = Keyboard.PreviewKeyDownEvent }); }); }