コード例 #1
0
        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.DotNet.ProjectModel.FileSystemGlobbing.Internal.PathSegments.WildcardPathSegment.MatchAll, segment);
                }
            });
        }
コード例 #2
0
ファイル: PatternTests.cs プロジェクト: akrisiun/dotnet-cli
        public void BuildLinearPatternNegative(string sample)
        {
            var builder = new PatternBuilder();
            var pattern = builder.Build(sample) as ILinearPattern;

            Assert.Null(pattern);
        }
コード例 #3
0
ファイル: PatternTests.cs プロジェクト: akrisiun/dotnet-cli
        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);
        }
コード例 #4
0
        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.");
            });
        }
コード例 #5
0
        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
ファイル: PatternTests.cs プロジェクト: akrisiun/dotnet-cli
        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
ファイル: Matcher.cs プロジェクト: akrisiun/dotnet-cli
 public Matcher(StringComparison comparisonType)
 {
     _comparison = comparisonType;
     _builder = new PatternBuilder(comparisonType);
 }
コード例 #8
0
ファイル: PatternTests.cs プロジェクト: akrisiun/dotnet-cli
 public void ThrowExceptionForNull()
 {
     Assert.Throws<ArgumentNullException>(() =>
     {
         var builder = new PatternBuilder();
         builder.Build(null);
     });
 }
コード例 #9
0
ファイル: PatternTests.cs プロジェクト: akrisiun/dotnet-cli
        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);
            });
        }