From 99e5625ca63810a9a81710772136244b66b9eed7 Mon Sep 17 00:00:00 2001 From: Deadpikle Date: Mon, 6 Apr 2020 17:34:56 -0400 Subject: [PATCH] Add failing test for cut not working with undo/redo --- .../TextBoxTests.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/Avalonia.Controls.UnitTests/TextBoxTests.cs b/tests/Avalonia.Controls.UnitTests/TextBoxTests.cs index 6bb3d55799..557c3920cc 100644 --- a/tests/Avalonia.Controls.UnitTests/TextBoxTests.cs +++ b/tests/Avalonia.Controls.UnitTests/TextBoxTests.cs @@ -554,6 +554,28 @@ namespace Avalonia.Controls.UnitTests } } + + [Fact] + public void Cut_Allows_Undo() + { + using (UnitTestApplication.Start(Services)) + { + var target = new TextBox + { + Template = CreateTemplate(), + Text = "0123" + }; + target.SelectionStart = 1; + target.SelectionEnd = 3; + + RaiseKeyEvent(target, Key.X, KeyModifiers.Control); // cut + Assert.True(target.Text == "03"); + + RaiseKeyEvent(target, Key.Z, KeyModifiers.Control); // undo + Assert.True(target.Text == "0123"); + } + } + private static TestServices FocusServices => TestServices.MockThreadingInterface.With( focusManager: new FocusManager(), keyboardDevice: () => new KeyboardDevice(),