Exemplo n.º 1
0
        public void OneServicePerBuffer()
        {
            var textBuffer = new TextBuffer("", MockFor<IContentType>().Object);

            var undoServiceFactory = new UndoServiceFactory();
            var undoService = undoServiceFactory.ForTextBuffer(textBuffer);
            Assert.AreSame(undoService, undoServiceFactory.ForTextBuffer(textBuffer));
        }
Exemplo n.º 2
0
        public void UndoInsertion()
        {
            var textBuffer = new TextBuffer("", MockFor<IContentType>().Object);

            var undoServiceFactory = new UndoServiceFactory();
            var undoService = undoServiceFactory.ForTextBuffer(textBuffer);

            var oldSnapshot = textBuffer.CurrentSnapshot;
            textBuffer.Insert(0, "text");

            var changes = new List<TextChangeArgs>();
            textBuffer.Changed += (sender, args) => changes.Add(args);
            undoService.Undo();
            Assert.AreEqual(1, changes.Count);

            Assert.AreSame(oldSnapshot, textBuffer.CurrentSnapshot);
        }
            public void WillNotCallTheTokenizerTwiceForTheSameLine()
            {
                var firstLineText = " ";

                var tokenizer = MockFor<IPartitionTokenizer>();
                tokenizer
                    .Setup(_ => _.Tokenize(PartitionTokenType.None, firstLineText))
                    .Returns(new[] { new PartitionToken(0, firstLineText.Length, PartitionTokenType.Code)});

                var buffer = new TextBuffer(firstLineText + "\n", ContentType());
                var secondLine = buffer.CurrentSnapshot.Lines[1];

                var subject = new PartitionTokenTypeCache(tokenizer.Object);
                Assert.AreEqual(PartitionTokenType.Code, subject.LastPartitionTokenTypeBefore(secondLine));
                Assert.AreEqual(PartitionTokenType.Code, subject.LastPartitionTokenTypeBefore(secondLine));

                VerifyAllMocks();
            }