Пример #1
0
            public void Should_Throw_If_Pattern_Is_Empty()
            {
                // Given
                var fixture = new GlobberFixture();
                var globber = fixture.CreateGlobber();

                // When
                var result = Record.Exception(() => globber.Match(null));

                // Then
                Assert.IsArgumentNullException(result, "pattern");
            }
Пример #2
0
            public void Should_Ignore_Case_Sensitivity_On_Case_Insensitive_Operative_System(bool isFileSystemCaseSensitive, bool shouldFindFile)
            {
                // Given
                var fixture = new GlobberFixture(isFileSystemCaseSensitive);
                var globber = fixture.CreateGlobber();

                // When
                var result = globber.Match("/Temp/**/text.txt").ToArray();

                // Then
                Assert.Equal(shouldFindFile, result.Length == 1);
            }
Пример #3
0
            public void Will_Append_Relative_Root_With_Implicit_Working_Directory()
            {
                // Given
                var fixture = new GlobberFixture();
                var globber = fixture.CreateGlobber();

                // When
                var result = globber.Match("Hello/World/Text.txt").ToArray();

                // Then
                Assert.Equal(1, result.Length);
                Assert.Equal("/Temp/Hello/World/Text.txt", result[0].FullPath);
            }
Пример #4
0
            public void Should_Throw_If_Unc_Root_Was_Encountered()
            {
                // Given
                var fixture = new GlobberFixture();
                var globber = fixture.CreateGlobber();

                // When
                var result = Record.Exception(() => globber.Match("//Hello/World/Text.txt"));

                // Then
                Assert.IsType <NotSupportedException>(result);
                Assert.Equal("UNC paths are not supported.", result.Message);
            }
Пример #5
0
            public void Can_Traverse_Recursivly()
            {
                // Given
                var fixture = new GlobberFixture();
                var globber = fixture.CreateGlobber();

                // When
                var result = globber.Match("/Temp/**/*.txt").ToArray();

                // Then
                Assert.Equal(2, result.Length);
                Assert.Equal("/Temp/Hello/World/Text.txt", result[0].FullPath);
                Assert.Equal("/Temp/Goodbye/OtherText.txt", result[1].FullPath);
            }
Пример #6
0
            public void Should_Return_Single_Path_For_Absolute_Directory_Path_Without_Glob_Pattern()
            {
                // Given
                var fixture = new GlobberFixture();
                var globber = fixture.CreateGlobber();

                // When
                var result = globber.Match("/Temp/Hello/World").ToArray();

                // Then
                Assert.Equal(1, result.Length);
                Assert.IsType <DirectoryPath>(result[0]);
                Assert.Equal("/Temp/Hello/World", result[0].FullPath);
            }
Пример #7
0
            public void Will_Fix_Root_If_Drive_Is_Missing_By_Using_The_Drive_From_The_Working_Directory()
            {
                // Given
                var fixture = new GlobberFixture();

                fixture.SetWorkingDirectory("C:/Working/");
                var globber = fixture.CreateGlobber();

                // When
                var result = globber.Match("/Temp/Hello/World/Text.txt").ToArray();

                // Then
                Assert.Equal(1, result.Length);
                Assert.Equal("C:/Temp/Hello/World/Text.txt", result[0].FullPath);
            }
Пример #8
0
            public void Should_Return_Single_Path_For_Relative_File_Path_Without_Glob_Pattern()
            {
                // Given
                var fixture = new GlobberFixture();

                fixture.SetWorkingDirectory("/Temp/Hello");
                var globber = fixture.CreateGlobber();

                // When
                var result = globber.Match("./World/Text.txt").ToArray();

                // Then
                Assert.Equal(1, result.Length);
                Assert.IsType <FilePath>(result[0]);
                Assert.Equal("/Temp/Hello/World/Text.txt", result[0].FullPath);
            }
Пример #9
0
            public void Should_Return_Single_Path_Glob_Pattern_With_Predicate()
            {
                // Given
                var fixture = new GlobberFixture();
                var globber = fixture.CreateGlobber();

                // When
                var result = globber.Match(
                    "./**/*.txt",
                    predicate => predicate.Path is DirectoryPath || predicate.Path.FullPath == "/Temp/Hello/World/Text.txt").ToArray();

                // Then
                Assert.Equal(1, result.Length);
                Assert.IsType <FilePath>(result[0]);
                Assert.Equal("/Temp/Hello/World/Text.txt", result[0].FullPath);
            }