Exemplo n.º 1
0
        public void Should_be_possible_to_get_the_unit_of_a_path()
        {
            var pathUnitWin  = new FilePathRegexInformation(@"c:\windows\temp").GetUnitOfPath();
            var pathUnitUnix = new FilePathRegexInformation("/lib/modules").GetUnitOfPath();

            Assert.AreEqual(@"c:\", pathUnitWin, "the path unit is not expected");
            Assert.IsNull(pathUnitUnix, "the path unit for unix system should always be null.");
        }
Exemplo n.º 2
0
        public void Should_return_the_empty_list_when_there_is_not_a_regex_pattern_in_the_path()
        {
            var fileLevelsWithRegexWin  = new FilePathRegexInformation(@"c:\windows\temp").GetPathLevelsWithRegex();
            var fileLevelsWithRegexUnix = new FilePathRegexInformation("/lib/modules").GetPathLevelsWithRegex();

            Assert.AreEqual(0, fileLevelsWithRegexWin.Count());
            Assert.AreEqual(0, fileLevelsWithRegexUnix.Count());
        }
Exemplo n.º 3
0
        public void Should_be_possible_to_get_patternMatch_levels()
        {
            {
                var fileLevelsWithRegexWin = new FilePathRegexInformation(@"c:\.*").GetPathLevelsWithRegex();
                AssertFilePathRegexInformation(fileLevelsWithRegexWin, 1, new string[] { ".*" }, new int[] { 1 });
            }

            {
                var fileLevelsWithRegexUnix = new FilePathRegexInformation("/.*").GetPathLevelsWithRegex();
                AssertFilePathRegexInformation(fileLevelsWithRegexUnix, 1, new string[] { ".*" }, new int[] { 0 });
            }
        }
Exemplo n.º 4
0
        public void Should_be_possible_to_concatenate_the_unix_path_with_next_regex_level()
        {
            {
                var pathWithNextRegex =
                    new FilePathRegexInformation("/.*/oval.*")
                    .ConcatPathWithNextLeveRegex("/temp/", 0);

                Assert.AreEqual("/temp/oval.*", pathWithNextRegex, "the path is not expected");
            }

            {
                var pathWithNextRegex =
                    new FilePathRegexInformation("/temp/file/.*/teste/^.txt")
                    .ConcatPathWithNextLeveRegex("/temp/file/temp/teste/", 2);

                Assert.AreEqual("/temp/file/temp/teste/^.txt", pathWithNextRegex, "the path is not expected");
            }
        }
Exemplo n.º 5
0
        public void Should_be_possible_to_concatenate_the_windows_path_with_next_regex_level()
        {
            {
                var pathWithNextRegex =
                    new FilePathRegexInformation(@"c:\.*\oval.*")
                    .ConcatPathWithNextLeveRegex(@"c:\temp\", 1);

                Assert.AreEqual(@"c:\temp\oval.*", pathWithNextRegex, "the path is not expected");
            }

            {
                var pathWithNextRegex =
                    new FilePathRegexInformation(@"c:\temp\file\.*\teste\^.txt")
                    .ConcatPathWithNextLeveRegex(@"c:\temp\file\temp\teste\", 3);

                Assert.AreEqual(@"c:\temp\file\temp\teste\^.txt", pathWithNextRegex, "the path is not expected");
            }
        }
Exemplo n.º 6
0
        public void Should_be_possible_to_get_patternMatch_levels_in_multiples_levels()
        {
            //  Windows
            {
                var fileLevelsWithRegex = new FilePathRegexInformation(@"c:\.*\oval.*").GetPathLevelsWithRegex();
                AssertFilePathRegexInformation(fileLevelsWithRegex, 2, new string[] { ".*", "oval.*" }, new int[] { 1, 2 });
            }
            {
                var fileLevelsWithRegex = new FilePathRegexInformation(@"c:\temp\oval.*\support\^[win]").GetPathLevelsWithRegex();
                AssertFilePathRegexInformation(fileLevelsWithRegex, 2, new string[] { "oval.*", "^[win]" }, new int[] { 2, 4 });
            }

            //  Unix
            {
                var fileLevelsWithRegex = new FilePathRegexInformation("/.*/oval.*").GetPathLevelsWithRegex();
                AssertFilePathRegexInformation(fileLevelsWithRegex, 2, new string[] { ".*", "oval.*" }, new int[] { 0, 1 });
            }
            {
                var fileLevelsWithRegex = new FilePathRegexInformation("/temp/oval.*/support/^[win]").GetPathLevelsWithRegex();
                AssertFilePathRegexInformation(fileLevelsWithRegex, 2, new string[] { "oval.*", "^[win]" }, new int[] { 1, 3 });
            }
        }
Exemplo n.º 7
0
        public void Should_be_possible_to_get_the_fixed_path_with_first_regex_pattern()
        {
            {
                var pathWithFirstRegexWin  = new FilePathRegexInformation(@"c:\.*\oval.*").GetPathWithFirstRegex();
                var pathWithFirstRegexUnix = new FilePathRegexInformation("/.*/oval.*").GetPathWithFirstRegex();
                AssertPathWithPattern(pathWithFirstRegexWin, @"c:\.*", 1);
                AssertPathWithPattern(pathWithFirstRegexUnix, "/.*", 0);
            }

            {
                var pathWithFirstRegexWin  = new FilePathRegexInformation(@"c:\temp\oval.*").GetPathWithFirstRegex();
                var pathWithFirstRegexUnix = new FilePathRegexInformation("/temp/oval.*").GetPathWithFirstRegex();
                AssertPathWithPattern(pathWithFirstRegexWin, @"c:\temp\oval.*", 2);
                AssertPathWithPattern(pathWithFirstRegexUnix, "/temp/oval.*", 1);
            }

            {
                var pathWithFirstRegexWin  = new FilePathRegexInformation(@"c:\temp\oval.*\xml").GetPathWithFirstRegex();
                var pathWithFirstRegexUnix = new FilePathRegexInformation("/temp/oval.*/xml").GetPathWithFirstRegex();
                AssertPathWithPattern(pathWithFirstRegexWin, @"c:\temp\oval.*", 2);
                AssertPathWithPattern(pathWithFirstRegexUnix, "/temp/oval.*", 1);
            }
        }