public void SearchRecursively_PatternWithThreeQuestionMarks_ReturnsEmpty()
        {
            // Arrange
            var mockFileSystem = CreateMockFileSystem();

            var ant = new AntDirectory(new Ant("/assets/dir1/*/file???.txt"), mockFileSystem);

            // Act
            var files = ant.SearchRecursively(XFS.Path(@"C:\"));

            // Assert
            files.Should().BeEmpty();
        }
        public void SearchRecursively_RecursiveFilesDoNotExist_ReturnsEmpty()
        {
            // Arrange
            var mockFileSystem = CreateMockFileSystem();

            var ant = new AntDirectory(new Ant("/assets/**/*.xml"), mockFileSystem);

            // Act
            var files = ant.SearchRecursively(XFS.Path(@"C:\"));

            // Assert
            files.Should().BeEmpty();
        }
        public void SearchRecursively_PatternWithQuestionMark_ReturnsTwoFiles()
        {
            // Arrange
            var mockFileSystem = CreateMockFileSystem();

            var ant = new AntDirectory(new Ant("/assets/dir1/*/file?.txt"), mockFileSystem);

            // Act
            var files = ant.SearchRecursively(XFS.Path(@"C:\")).ToList();

            // Assert
            files.Should().HaveCount(2);
            files.Should().Contain(f => f == XFS.Path(@"assets\dir1\dir1_1\file1.txt"));
            files.Should().Contain(f => f == XFS.Path(@"assets\dir1\dir1_1\file2.txt"));
        }
        public void SearchRecursively_WithDirectoryPathSetting_ReturnsExpectedValue(
            bool includeDirectoryPath)
        {
            var ant   = new AntDirectory(new Ant("/assets/dir1/*/file?.txt"), CreateMockFileSystem());
            var match = ant.SearchRecursively(XFS.Path(@"C:\"), includeDirectoryPath);

            if (includeDirectoryPath)
            {
                match.First().Should().StartWith(XFS.Path(@"C:\"));
            }
            else
            {
                match.First().Should().NotStartWith(XFS.Path(@"C:\"));
            }
        }
예제 #5
0
        public void SearchRecursively_RecursiveFilesExist_ReturnsTwoFiles()
        {
            // Arrange
            var mockFileSystem = CreateMockFileSystem();

            var ant = new AntDirectory(new Ant("/assets/**/*.txt"), mockFileSystem);

            // Act
            var files = ant.SearchRecursively(@"C:\").ToList();

            // Assert
            files.Should().HaveCount(2);
            files.Should().Contain(f => f == @"assets\dir1\dir1_1\file1.txt");
            files.Should().Contain(f => f == @"assets\dir1\dir1_1\file2.txt");
        }
        public void SearchRecursively_PatternRecursiveWithWildcard_ReturnsThreeFiles()
        {
            // Arrange
            var mockFileSystem = CreateMockFileSystem();

            var ant = new AntDirectory(new Ant("/assets/**/*.*"), mockFileSystem);

            // Act
            var files = ant.SearchRecursively(XFS.Path(@"C:\")).ToList();

            // Assert
            files.Should().HaveCount(3);
            files.Should().Contain(f => f == XFS.Path(@"assets\dir1\dir1_1\file1.txt"));
            files.Should().Contain(f => f == XFS.Path(@"assets\dir1\dir1_1\file2.txt"));
            files.Should().Contain(f => f == XFS.Path(@"assets\dir2\file2.zip"));
        }
        public void SearchRecursively_WhenDirectoryNotFound_DoesNotThrow()
        {
            var ant = new AntDirectory(new Ant("*.txt"), new MockFileSystem());

            Assert.DoesNotThrow(() => ant.SearchRecursively(XFS.Path(@"C:\Octopus\Applications\production\Containers")).ToList());
        }