Exemple #1
0
        public void TryMerge_WithBackspace_DoesNotWorkWhenInsertionIsEmpty()
        {
            var fakeInsertion =
                new InsertTextCommand.InsertTextUndoableAction(BlockAt <TextBlock>(0).BeginCursor().ToHandle(),
                                                               "1234");

            fakeInsertion.Do(Context);
            Context.UndoStack.Clear();

            var insertion =
                new InsertTextCommand.InsertTextUndoableAction(BlockAt <TextBlock>(0).BeginCursor().ToHandle(), "");

            insertion.Do(Context);
            var second =
                new DeletePreviousCharacterCommand.DeletePreviousCharacterAction(
                    BlockAt <TextBlock>(0).BeginCaret(4).AsTextCursor());

            DidYouKnow.That(insertion.TryMerge(Context, second)).Should().BeFalse();
        }
Exemple #2
0
        public void TryMerge_WithBackspaceAction_Works()
        {
            BlockAt <TextBlock>(0).GetCaretAtStart().AsTextCursor().InsertText("This is text");

            var insertion =
                new InsertTextCommand.InsertTextUndoableAction(BlockAt <TextBlock>(0).BeginCursor().ToHandle(),
                                                               "Inserted String");

            insertion.Do(Context);
            var second =
                new DeletePreviousCharacterCommand.DeletePreviousCharacterAction(
                    BlockAt <TextBlock>(0).BeginCaret(insertion.Text.Length).AsTextCursor());

            DidYouKnow.That(insertion.TryMerge(Context, second)).
            Should().BeTrue();

            DidYouKnow.That(insertion.Text).Should()
            .Be("Inserted Strin");
        }