public void TestFileForIncludeReturnsCorrectResult(string[] testSegments, string[] pushDirectory, string filename, bool expectResult)
        {
            var pattern = MockLinearPatternBuilder.New().Add(testSegments).Build();
            var context = new PatternContextLinearInclude(pattern);
            PatternContextHelper.PushDirectory(context, pushDirectory);

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

            Assert.Equal(expectResult, result.IsSuccessful);
        }
        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.");
            });
        }
        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.");
                });
            });
        }
        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);
            });
        }