Exemplo n.º 1
0
            public void WillFindNoFilesIfADirectoryDoesNotExist()
            {
                // Arrange
                dataSource = new RuntimeFilePathDataSource("ThisPathDoesNotExist", "*.json");

                // Act
                var filePaths = dataSource.GetData(throwAwayMethodInfo).ToList();

                // Assert
                filePaths.Count().Should().Be(0, because: "that path does not exist. ");
            }
Exemplo n.º 2
0
            public void WillFindNoMatchesIfTheFolderExistsButNoFilesMatchThePattern()
            {
                // Arrange
                dataSource = new RuntimeFilePathDataSource("DataSource", "*.notjson");

                // Act
                var filePaths = dataSource.GetData(throwAwayMethodInfo).ToList();

                // Assert
                filePaths.Count().Should().Be(0, because: "the path exists but there were no matching patterns. ");
            }
Exemplo n.º 3
0
            public void WillMatchFilesRecursively()
            {
                // Arrange
                dataSource = new RuntimeFilePathDataSource("DataSource/RuntimeFilePathTestData", "*.json");

                // Act
                var filePaths = dataSource.GetData(throwAwayMethodInfo).ToList();

                // Assert
                filePaths.Count().Should().Be(3, because: "there are three matching files in total for the runtime file test. ");
            }
Exemplo n.º 4
0
            public void WillFindOneFileThatMatchesThePattern()
            {
                // Arrange
                dataSource = new RuntimeFilePathDataSource("DataSource/RuntimeFilePathTestData/OneMatchingFile", "*.json");

                // Act
                var filePaths = dataSource.GetData(throwAwayMethodInfo).ToList();

                // Assert
                filePaths.Count().Should().Be(1, because: "there is exactly one matching file under that path. ");

                var path     = $"{filePaths[0][0]}";
                var filename = System.IO.Path.GetFileName(path);

                filename.Should().Be("thisOneMatches.json", because: "there is only one match");
            }
Exemplo n.º 5
0
            public void WillFindTwoFilesThatMatchesThePattern()
            {
                // Arrange
                dataSource = new RuntimeFilePathDataSource("DataSource/RuntimeFilePathTestData/TwoMatchingFiles", "*.json");

                // Act
                var filePaths = dataSource.GetData(throwAwayMethodInfo).ToList();

                // Assert
                filePaths.Count().Should().Be(2, because: "there are two matching files. ");

                var path1     = $"{filePaths[0][0]}";
                var path2     = $"{filePaths[1][0]}";
                var filename1 = System.IO.Path.GetFileName(path1);
                var filename2 = System.IO.Path.GetFileName(path2);

                filename1.Should().BeOneOf("thisMatches.json", "thisMatchesToo.json");
                filename2.Should().BeOneOf("thisMatches.json", "thisMatchesToo.json");
            }