Clear() публичный Метод

public Clear ( ) : void
Результат void
Пример #1
0
        internal void ClearChanges()
        {
            if (Thread.CurrentThread.ManagedThreadId != _ownerThreadId)
            {
                throw new ThreadStateException("Method should only be called on the main thread");
            }

            _pendingChanges.Clear();
        }
Пример #2
0
        public void TextChange_Test() {
            TextChange tc = new TextChange();
            tc.IsEmpty.Should().BeTrue();
            tc.TextChangeType.Should().Be(TextChangeType.Trivial);

            string content = "23456789";
            TextBufferMock textBuffer = new TextBufferMock(content, RContentTypeDefinition.ContentType);
            ITextSnapshot oldSnapshot = textBuffer.CurrentSnapshot;

            textBuffer.Insert(0, "1");
            ITextSnapshot newSnapshot1 = textBuffer.CurrentSnapshot;

            textBuffer.Insert(0, "0");
            ITextSnapshot newSnapshot2 = textBuffer.CurrentSnapshot;

            tc.OldTextProvider = new TextProvider(oldSnapshot);
            tc.NewTextProvider = new TextProvider(newSnapshot1);

            tc.OldRange = new TextRange(0, 0);
            tc.NewRange = new TextRange(0, 1);

            var tc1 = new TextChange(tc, new TextProvider(newSnapshot2));

            tc1.ShouldBeEquivalentTo(new {
                OldRange = new { Length = 0 },
                NewRange = new { Length = 2 },
                Version = 2,
                FullParseRequired = false,
                IsEmpty = false,
                IsSimpleChange = true
            }, o => o.ExcludingMissingMembers());

            var tc2 = tc1.Clone() as TextChange;

            tc2.ShouldBeEquivalentTo(new {
                OldRange = new { Length = 0 },
                NewRange = new { Length = 2 },
                Version = 2,
                FullParseRequired = false,
                IsEmpty = false,
                IsSimpleChange = true
            }, o => o.ExcludingMissingMembers());

            tc1.Clear();

            tc1.ShouldBeEquivalentTo(new {
                OldRange = new { Length = 0 },
                NewRange = new { Length = 0 },
                OldTextProvider = (ITextProvider)null,
                NewTextProvider = (ITextProvider)null,
                IsEmpty = true,
                IsSimpleChange = true
            }, o => o.ExcludingMissingMembers());

            tc2.ShouldBeEquivalentTo(new {
                OldRange = new { Length = 0 },
                NewRange = new { Length = 2 },
                Version = 2,
                FullParseRequired = false,
                IsEmpty = false,
                IsSimpleChange = true
            }, o => o.ExcludingMissingMembers());
        }
Пример #3
0
        public void TextChange_Test()
        {
            TextChange tc = new TextChange();

            tc.IsEmpty.Should().BeTrue();
            tc.TextChangeType.Should().Be(TextChangeType.Trivial);

            string         content     = "23456789";
            TextBufferMock textBuffer  = new TextBufferMock(content, RContentTypeDefinition.ContentType);
            ITextSnapshot  oldSnapshot = textBuffer.CurrentSnapshot;

            textBuffer.Insert(0, "1");
            ITextSnapshot newSnapshot1 = textBuffer.CurrentSnapshot;

            textBuffer.Insert(0, "0");
            ITextSnapshot newSnapshot2 = textBuffer.CurrentSnapshot;

            tc.OldTextProvider = new TextProvider(oldSnapshot);
            tc.NewTextProvider = new TextProvider(newSnapshot1);

            tc.OldRange = new TextRange(0, 0);
            tc.NewRange = new TextRange(0, 1);

            var tc1 = new TextChange(tc, new TextProvider(newSnapshot2));

            tc1.ShouldBeEquivalentTo(new {
                OldRange          = new { Length = 0 },
                NewRange          = new { Length = 2 },
                Version           = 2,
                FullParseRequired = false,
                IsEmpty           = false,
                IsSimpleChange    = true
            }, o => o.ExcludingMissingMembers());

            var tc2 = tc1.Clone() as TextChange;

            tc2.ShouldBeEquivalentTo(new {
                OldRange          = new { Length = 0 },
                NewRange          = new { Length = 2 },
                Version           = 2,
                FullParseRequired = false,
                IsEmpty           = false,
                IsSimpleChange    = true
            }, o => o.ExcludingMissingMembers());

            tc1.Clear();

            tc1.ShouldBeEquivalentTo(new {
                OldRange        = new { Length = 0 },
                NewRange        = new { Length = 0 },
                OldTextProvider = (ITextProvider)null,
                NewTextProvider = (ITextProvider)null,
                IsEmpty         = true,
                IsSimpleChange  = true
            }, o => o.ExcludingMissingMembers());

            tc2.ShouldBeEquivalentTo(new {
                OldRange          = new { Length = 0 },
                NewRange          = new { Length = 2 },
                Version           = 2,
                FullParseRequired = false,
                IsEmpty           = false,
                IsSimpleChange    = true
            }, o => o.ExcludingMissingMembers());
        }