Exemple #1
0
        public void Break_AtBeginning_HasNewBlock()
        {
            Initialize("abc|123");
            var nextBlock = (TextBlock)TextBlockHelperMethods.TryBreakBlock(_caret).Block;

            DidYouKnow.That(nextBlock).Should().NotBeNull();

            DidYouKnow.That(_block.Content.GetText()).Should().Be("abc");
            DidYouKnow.That(nextBlock.Content.GetText()).Should().Be("123");
        }
        public void BreakAtEnd_MakesNewNextEmptyBlock()
        {
            var cursor = (TextCaret)_collection.NthBlock(0).EndCaret();

            var newBlock = TextBlockHelperMethods.TryBreakBlock(cursor).Block;

            DidYouKnow.That(_collection.ChildCount).Should().Be(3);
            DidYouKnow.That(_collection.NthBlock(0).AsText()).Should().Be("This is line #1");
            DidYouKnow.That(_collection.NthBlock(1).AsText()).Should().Be("");
            DidYouKnow.That(_collection.NthBlock(2).AsText()).Should().Be("This is line #2");

            DidYouKnow.That(newBlock).Should().Be(_collection.NthBlock(1));
        }
        public void VerifyBreakInMiddleOfParagraph_SplitsIntoTwo()
        {
            var cursor = (TextCaret)_collection.NthBlock(0).BeginCaret();

            cursor = cursor.MoveCursorForwardBy(7); // should be after "is"

            var newBlock = TextBlockHelperMethods.TryBreakBlock(cursor).Block;

            DidYouKnow.That(_collection.ChildCount).Should().Be(3);
            DidYouKnow.That(_collection.NthBlock(0).AsText()).Should().Be("This is");
            DidYouKnow.That(_collection.NthBlock(1).AsText()).Should().Be(" line #1");
            DidYouKnow.That(_collection.NthBlock(2).AsText()).Should().Be("This is line #2");

            DidYouKnow.That(newBlock).Should().Be(_collection.NthBlock(1));
        }