コード例 #1
0
        public void TestFileForExcludeReturnsCorrectResult(string[] testSegments, string[] pushDirectory, string filename, bool expectResult)
        {
            var pattern = MockLinearPatternBuilder.New().Add(testSegments).Build();
            var context = new PatternContextLinearExclude(pattern);

            PatternContextHelper.PushDirectory(context, pushDirectory);

            var result = context.Test(new FakeFileInfo(filename));

            Assert.Equal(expectResult, result.IsSuccessful);
        }
コード例 #2
0
        public void TestDirectoryForIncludeReturnsCorrectResult(string[] testSegments, string[] pushDirectory, string directoryName, bool expectResult)
        {
            var pattern = MockLinearPatternBuilder.New().Add(testSegments).Build();
            var context = new PatternContextLinearInclude(pattern);

            PatternContextHelper.PushDirectory(context, pushDirectory);

            var result = context.Test(new FakeDirectoryInfo(directoryName));

            Assert.Equal(expectResult, result);
        }
コード例 #3
0
        public void PredictNotCallBackWhenEnterUnmatchDirectory(string[] testSegments, string[] pushDirectory)
        {
            var pattern = MockLinearPatternBuilder.New().Add(testSegments).Build();
            var context = new PatternContextLinearInclude(pattern);

            PatternContextHelper.PushDirectory(context, pushDirectory);

            context.Declare((segment, last) =>
            {
                Assert.False(true, "No segment should be declared.");
            });
        }
コード例 #4
0
        public void PredictBeforeEnterDirectoryShouldThrow()
        {
            var pattern = MockLinearPatternBuilder.New().Add("a").Build();
            var context = new PatternContextLinearInclude(pattern);

            Assert.Throws <InvalidOperationException>(() =>
            {
                context.Declare((segment, last) =>
                {
                    Assert.False(true, "No segment should be declared.");
                });
            });
        }
コード例 #5
0
        public void PredictReturnsCorrectResult(string[] testSegments, string[] pushDirectory, string expectSegment, bool expectLast)
        {
            var pattern = MockLinearPatternBuilder.New().Add(testSegments).Build();
            var context = new PatternContextLinearInclude(pattern);

            PatternContextHelper.PushDirectory(context, pushDirectory);

            context.Declare((segment, last) =>
            {
                var literal = segment as MockNonRecursivePathSegment;

                Assert.NotNull(segment);
                Assert.Equal(expectSegment, literal.Value);
                Assert.Equal(expectLast, last);
            });
        }