示例#1
0
        public void BuildLinearPatternNegative(string sample)
        {
            var builder = new PatternBuilder();
            var pattern = builder.Build(sample) as ILinearPattern;

            Assert.Null(pattern);
        }
        public void PredictReturnsCorrectResult(string patternString, string[] pushDirectory, string expectSegment, bool expectWildcard)
        {
            var builder = new PatternBuilder();
            var pattern = builder.Build(patternString) as IRaggedPattern;
            Assert.NotNull(pattern);

            var context = new PatternContextRaggedInclude(pattern);
            PatternContextHelper.PushDirectory(context, pushDirectory);

            context.Declare((segment, last) =>
            {
                if (expectSegment != null)
                {
                    var mockSegment = segment as LiteralPathSegment;

                    Assert.NotNull(mockSegment);
                    Assert.Equal(false, last);
                    Assert.Equal(expectSegment, mockSegment.Value);
                }
                else
                {
                    Assert.Equal(Microsoft.Framework.FileSystemGlobbing.Internal.PathSegments.WildcardPathSegment.MatchAll, segment);
                }
            });
        }
示例#3
0
        public void BuildLinearPattern(string sample, int segmentCount)
        {
            var builder = new PatternBuilder();
            var pattern = builder.Build(sample);

            Assert.True(pattern is ILinearPattern);
            Assert.Equal(segmentCount, (pattern as ILinearPattern).Segments.Count);
        }
        public void PredictNotCallBackWhenEnterUnmatchDirectory(string patternString, string[] pushDirectory)
        {
            var builder = new PatternBuilder();
            var pattern = builder.Build(patternString) as IRaggedPattern;
            var context = new PatternContextRaggedInclude(pattern);
            PatternContextHelper.PushDirectory(context, pushDirectory);

            context.Declare((segment, last) =>
            {
                Assert.False(true, "No segment should be declared.");
            });
        }
        public void PredictBeforeEnterDirectoryShouldThrow()
        {
            var builder = new PatternBuilder();
            var pattern = builder.Build("**") as IRaggedPattern;
            var context = new PatternContextRaggedInclude(pattern);

            Assert.Throws<InvalidOperationException>(() =>
            {
                context.Declare((segment, last) =>
                {
                    Assert.False(true, "No segment should be declared.");
                });
            });
        }
示例#6
0
        public void BuildRaggedPattern(string sample,
                             int segmentCount,
                             int startSegmentsCount,
                             int containSegmentCount,
                             int endSegmentCount)
        {
            var builder = new PatternBuilder();
            var pattern = builder.Build(sample) as IRaggedPattern;

            Assert.NotNull(pattern);
            Assert.Equal(segmentCount, pattern.Segments.Count);
            Assert.Equal(startSegmentsCount, pattern.StartsWith.Count);
            Assert.Equal(endSegmentCount, pattern.EndsWith.Count);
            Assert.Equal(containSegmentCount, pattern.Contains.Count);
        }
示例#7
0
 public void ThrowExceptionForNull()
 {
     Assert.Throws<ArgumentNullException>(() =>
     {
         var builder = new PatternBuilder();
         builder.Build(null);
     });
 }
示例#8
0
        public void ThrowExceptionForInvalidParentsPath(string sample)
        {
            // parent segment is only allowed at the beginning of the pattern
            Assert.Throws<ArgumentException>(() =>
            {
                var builder = new PatternBuilder();
                var pattern = builder.Build(sample);

                Assert.Null(pattern);
            });
        }
示例#9
0
 public Matcher(StringComparison comparisonType)
 {
     _comparison = comparisonType;
     _builder = new PatternBuilder(comparisonType);
 }