Exemplo n.º 1
0
        public void VisitSegmentDoesNotLockSegmentWhenWholeSegmentDoesNotMatch()
        {
            // Arrange
            var settings = utility.CreateSettings(useContentLocker: true,
                                                  segmentLockItem: new SegmentLockItem()
            {
                IsRegex    = true,
                SearchText = @"^[0-9]+$"
            });

            var segment         = utility.CreateSegment();
            var txt1            = utility.CreateText(text: "12345", segment: segment);
            var txt2            = utility.CreateText(text: "not a number", segment: segment);
            var itemFactory     = Substitute.For <IDocumentItemFactory>();
            var reporter        = Substitute.For <ICleanUpMessageReporter>();
            var reportGenerator = Substitute.For <IXmlReportGenerator>();
            var handler         = new LockHandler(settings, itemFactory, reporter, reportGenerator);

            // Act
            handler.VisitText(txt1);
            handler.VisitText(txt2);
            handler.VisitSegment(segment);

            Assert.False(segment.Properties.IsLocked);
        }
Exemplo n.º 2
0
        public void VisitSegmentIgnoresInvalidRegexExpressions()
        {
            // Arrange
            var settings = utility.CreateSettings(useContentLocker: true,
                                                  segmentLockItem: new SegmentLockItem()
            {
                IsRegex    = true,
                SearchText = @"^[ ("
            });

            var segment         = utility.CreateSegment(isLocked: false);
            var txt             = utility.CreateText(text: "whatever", segment: segment);
            var itemFactory     = Substitute.For <IDocumentItemFactory>();
            var reporter        = Substitute.For <ICleanUpMessageReporter>();
            var reportGenerator = Substitute.For <IXmlReportGenerator>();
            var handler         = new LockHandler(settings, itemFactory, reporter, reportGenerator);

            // Act
            handler.VisitText(txt);
            handler.VisitSegment(segment);

            Assert.False(segment.Properties.IsLocked);
        }
Exemplo n.º 3
0
        public void VisitTextDoesNotLockSegmentOnWholeWordNoMatch()
        {
            // Arrange
            var settings = utility.CreateSettings(useContentLocker: true,
                                                  segmentLockItem: new SegmentLockItem()
            {
                WholeWord  = true,
                SearchText = @"d"
            });

            var segment         = utility.CreateSegment();
            var txt             = utility.CreateText(text: "hidden dad dear red", segment: segment);
            var itemFactory     = Substitute.For <IDocumentItemFactory>();
            var reporter        = Substitute.For <ICleanUpMessageReporter>();
            var reportGenerator = Substitute.For <IXmlReportGenerator>();
            var handler         = new LockHandler(settings, itemFactory, reporter, reportGenerator);

            // Act
            handler.VisitText(txt);
            handler.VisitSegment(segment);

            Assert.False(segment.Properties.IsLocked);
        }
Exemplo n.º 4
0
        public void VisitSegmentsLocksSegmentsOnNormalMatch()
        {
            // Arrange
            var settings = utility.CreateSettings(useContentLocker: true,
                                                  segmentLockItem: new SegmentLockItem()
            {
                IsRegex    = false,
                SearchText = "123"
            });

            var segment         = utility.CreateSegment();
            var txt             = utility.CreateText(text: "ABCabc123%- ", segment: segment);
            var itemFactory     = Substitute.For <IDocumentItemFactory>();
            var reporter        = Substitute.For <ICleanUpMessageReporter>();
            var reportGenerator = Substitute.For <IXmlReportGenerator>();
            var handler         = new LockHandler(settings, itemFactory, reporter, reportGenerator);

            // Act
            handler.VisitText(txt);
            handler.VisitSegment(segment);

            Assert.True(segment.Properties.IsLocked);
        }
Exemplo n.º 5
0
        public void VisitSegmentIgnoresSegmentsOnCaseSensitiveRegex()
        {
            // Arrange
            var settings = utility.CreateSettings(useContentLocker: true,
                                                  segmentLockItem: new SegmentLockItem()
            {
                IsRegex         = true,
                IsCaseSensitive = true,
                SearchText      = @"[A-Z]+"
            });

            var segment         = utility.CreateSegment();
            var txt             = utility.CreateText(text: "abcdefg", segment: segment);
            var itemFactory     = Substitute.For <IDocumentItemFactory>();
            var reporter        = Substitute.For <ICleanUpMessageReporter>();
            var reportGenerator = Substitute.For <IXmlReportGenerator>();
            var handler         = new LockHandler(settings, itemFactory, reporter, reportGenerator);

            // Act
            handler.VisitText(txt);
            handler.VisitSegment(segment);

            Assert.False(segment.Properties.IsLocked);
        }