コード例 #1
0
            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");
            }
コード例 #2
0
            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);
            }
コード例 #3
0
            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");
            }
コード例 #4
0
            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();
            }
コード例 #5
0
            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);
            }
コード例 #6
0
            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);
            }
コード例 #7
0
            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("/嵌套/目录/文件.延期");
            }
コード例 #8
0
            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");
            }
コード例 #9
0
            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);
            }
コード例 #10
0
            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);
            }
コード例 #11
0
            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);
            }
コード例 #12
0
            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.");
            }
コード例 #13
0
            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");
            }
コード例 #14
0
            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");
            }
コード例 #15
0
            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");
            }
コード例 #16
0
            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");
            }
コード例 #17
0
            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");
            }
コード例 #18
0
            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, "/嵌套/目录/文件.延期");
            }
コード例 #19
0
            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");
            }
コード例 #20
0
            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");
            }
コード例 #21
0
                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);
                }
コード例 #22
0
            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");
            }
コード例 #23
0
            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");
            }
コード例 #24
0
            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");
            }
コード例 #25
0
            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");
            }
コード例 #26
0
            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");
            }
コード例 #27
0
                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();
                }
コード例 #28
0
            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");
            }
コード例 #29
0
            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);
            }
コード例 #30
0
            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");
            }