public void Should_Return_Files_And_Folders_For_Pattern_Ending_With_Wildcard() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/Working/**/*"); // Then Assert.Equal(18, result.Length); AssertEx.ContainsDirectoryPath(result, "/Working/Foo"); AssertEx.ContainsDirectoryPath(result, "/Working/Foo/Bar"); AssertEx.ContainsDirectoryPath(result, "/Working/Foo/Baz"); AssertEx.ContainsDirectoryPath(result, "/Working/Foo/Bar/Baz"); AssertEx.ContainsDirectoryPath(result, "/Working/Bar"); AssertEx.ContainsFilePath(result, "/Working/Foo/Bar/Qux.c"); AssertEx.ContainsFilePath(result, "/Working/Foo/Bar/Qex.c"); AssertEx.ContainsFilePath(result, "/Working/Foo/Bar/Qux.h"); AssertEx.ContainsFilePath(result, "/Working/Foo/Baz/Qux.c"); AssertEx.ContainsFilePath(result, "/Working/Foo/Bar/Baz/Qux.c"); AssertEx.ContainsFilePath(result, "/Working/Foo.Bar.Test.dll"); AssertEx.ContainsFilePath(result, "/Working/Bar.Qux.Test.dll"); AssertEx.ContainsFilePath(result, "/Working/Quz.FooTest.dll"); AssertEx.ContainsFilePath(result, "/Working/Bar/Qux.c"); AssertEx.ContainsFilePath(result, "/Working/Bar/Qux.h"); AssertEx.ContainsFilePath(result, "/Working/foobar.rs"); AssertEx.ContainsFilePath(result, "/Working/foobaz.rs"); AssertEx.ContainsFilePath(result, "/Working/foobax.rs"); }
public void Should_Return_Empty_Result_If_Pattern_Is_Invalid() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("pattern/"); // Then Assert.Empty(result); }
public void Should_Throw_If_Pattern_Is_Null() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = Record.Exception(() => fixture.Match(null)); // Then AssertEx.IsArgumentNullException(result, "pattern"); }
public void Should_Return_Empty_Result_If_Pattern_Is_Empty() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match(string.Empty); // Then result.ShouldBeEmpty(); }
public void Should_Include_Folder_In_Root_Folder_When_Using_Recursive_Wildcard(string pattern, string folder) { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match(pattern); // Then Assert.Single(result); AssertEx.ContainsDirectoryPath(result, folder); }
public void Should_Include_Files_In_Root_Folder_When_Using_Wildcard(string pattern, string file) { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match(pattern); // Then Assert.Single(result); AssertEx.ContainsFilePath(result, file); }
public void Should_Parse_Glob_Expressions_With_Unicode_Characters_And_Not_Ending_With_Identifier() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/嵌套/**/文件.*"); // Then result.Length.ShouldBe(1); result.ShouldContainFilePath("/嵌套/目录/文件.延期"); }
public void Should_Parse_Glob_Expressions_With_AtSign_In_Them() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/Foo@Bar/Baz.*"); // Then result.Length.ShouldBe(1); result.ShouldContainFilePath("/Foo@Bar/Baz.c"); }
public void Should_Include_Folder_In_Root_Folder_When_Using_Recursive_Wildcard(string pattern, string folder) { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match(pattern); // Then result.Length.ShouldBe(1); result.ShouldContainDirectoryPath(folder); }
public void Should_Include_Files_In_Root_Folder_When_Using_Wildcard(string pattern, string file) { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match(pattern); // Then result.Length.ShouldBe(1); result.ShouldContainFilePath(file); }
public void Should_Return_Single_Path_For_Absolute_Directory_Path_Without_Glob_Pattern(string pattern) { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match(pattern); // Then result.Length.ShouldBe(1); result.ShouldContainDirectoryPath(pattern); }
public void Should_Throw_If_Visiting_Parent_That_Is_Recursive_Wildcard() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = Record.Exception(() => fixture.Match("/Working/Foo/**/../Foo/Bar/Qux.c")); // Then result.ShouldBeOfType <NotSupportedException>() .And().Message.ShouldBe("Visiting a parent that is a recursive wildcard is not supported."); }
public void Should_Be_Able_To_Visit_Parent_Using_Double_Dots() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/Working/Foo/../Foo/Bar/Qux.c"); // Then result.Length.ShouldBe(1); result.ShouldContainFilePath("/Working/Foo/Bar/Qux.c"); }
public void Will_Append_Relative_Root_With_Implicit_Working_Directory() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("Foo/Bar/Qux.c"); // Then result.Length.ShouldBe(1); result.ShouldContainFilePath("/Working/Foo/Bar/Qux.c"); }
public void Will_Append_Relative_Root_With_Implicit_Working_Directory() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("Foo/Bar/Qux.c"); // Then Assert.Single(result); AssertEx.ContainsFilePath(result, "/Working/Foo/Bar/Qux.c"); }
public void Should_Throw_If_Pattern_Is_Null() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = Record.Exception(() => fixture.Match(null)); // Then result.ShouldBeOfType <ArgumentNullException>() .And().ParamName.ShouldBe("pattern"); }
public void Should_Include_Folder_In_Root_Folder_When_Using_Recursive_Wildcard() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/Foo/**/Bar"); // Then Assert.Single(result); AssertEx.ContainsDirectoryPath(result, "/Foo/Bar"); }
public void Should_Parse_Glob_Expressions_With_Unicode_Characters_And_Not_Ending_With_Identifier() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/嵌套/**/文件.*"); // Then Assert.Single(result); AssertEx.ContainsFilePath(result, "/嵌套/目录/文件.延期"); }
public void Should_Parse_Glob_Expressions_With_AtSign_In_Them() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/Foo@Bar/Baz.*"); // Then Assert.Single(result); AssertEx.ContainsFilePath(result, "/Foo@Bar/Baz.c"); }
public void Should_Return_Single_Path_For_Absolute_Directory_Path_Without_Glob_Pattern() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/Working/Foo/Bar"); // Then Assert.Single(result); AssertEx.ContainsDirectoryPath(result, "/Working/Foo/Bar"); }
public void Should_Not_Return_Path_If_Walker_Hint_Exactly_Match_Pattern() { // Given var fixture = GlobberFixture.UnixLike(); var predicate = new Func <IFileSystemInfo, bool>(i => i.Path.FullPath != "/Working/Bar"); // When var result = fixture.Match("/Working/Bar", predicate); // Then Assert.Empty(result); }
public void Should_Return_Files_And_Folders_For_Pattern_Containing_Negated_Bracket_Wildcard() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/Working/fooba[!x].rs"); // Then Assert.Equal(2, result.Length); AssertEx.ContainsFilePath(result, "/Working/foobar.rs"); AssertEx.ContainsFilePath(result, "/Working/foobaz.rs"); }
public void Should_Return_Files_And_Folders_For_Pattern_Containing_Brace_Expansion() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/Working/foo{bar,bax}.rs"); // Then Assert.Equal(2, result.Length); AssertEx.ContainsFilePath(result, "/Working/foobar.rs"); AssertEx.ContainsFilePath(result, "/Working/foobax.rs"); }
public void Should_Parse_Glob_Expressions_With_Relative_Directory_Not_At_The_Beginning() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/Working/./*.Test.dll"); // Then Assert.Equal(2, result.Length); AssertEx.ContainsFilePath(result, "/Working/Foo.Bar.Test.dll"); AssertEx.ContainsFilePath(result, "/Working/Bar.Qux.Test.dll"); }
public void Should_Return_Files_For_Pattern_Ending_With_Character_Wildcard_And_Dot() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/Working/*.Test.dll"); // Then Assert.Equal(2, result.Length); AssertEx.ContainsFilePath(result, "/Working/Foo.Bar.Test.dll"); AssertEx.ContainsFilePath(result, "/Working/Bar.Qux.Test.dll"); }
public void Should_Return_Files_And_Folders_For_Pattern_Containing_Character_Wildcard() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/Working/Foo/Ba?/Qux.c"); // Then Assert.Equal(2, result.Length); AssertEx.ContainsFilePath(result, "/Working/Foo/Bar/Qux.c"); AssertEx.ContainsFilePath(result, "/Working/Foo/Baz/Qux.c"); }
public void Should_Not_Return_Path_If_Walker_Hint_Matches_Part_Of_Pattern() { // Given var fixture = GlobberFixture.UnixLike(); var predicate = new Func <IFileSystemInfo, bool>(i => i.Path.FullPath != "/Working/Bar"); // When var result = fixture.Match("/Working/Bar/Qux.h", predicate); // Then result.ShouldBeEmpty(); }
public void Should_Return_Single_Path_For_Absolute_File_Path_Without_Glob_Pattern() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/Working/Foo/Bar/Qux.c"); // Then Assert.Single(result); Assert.IsType <FilePath>(result[0]); AssertEx.ContainsFilePath(result, "/Working/Foo/Bar/Qux.c"); }
public void Should_Throw_If_Visiting_Parent_That_Is_Recursive_Wildcard() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = Record.Exception(() => fixture.Match("/Working/Foo/**/../Foo/Bar/Qux.c")); // Then Assert.NotNull(result); Assert.IsType <NotSupportedException>(result); Assert.Equal("Visiting a parent that is a recursive wildcard is not supported.", result?.Message); }
public void Should_Be_Able_To_Visit_Parent_Using_Double_Dots() { // Given var fixture = GlobberFixture.UnixLike(); // When var result = fixture.Match("/Working/Foo/../Foo/Bar/Qux.c"); // Then Assert.Single(result); Assert.IsType <FilePath>(result[0]); AssertEx.ContainsFilePath(result, "/Working/Foo/Bar/Qux.c"); }