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); }
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); }
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); }); }