Ejemplo n.º 1
0
        public string[] GetPuzzleFilePathsFromPuzzleDirectory(string puzzleDirectory, int maximumNumberOfFiles)
        {
            string puzzleDirectoryPath = $"{_fileOperations.ApplicationBasePath("WordSearch")}{Path.DirectorySeparatorChar}{puzzleDirectory}";

            if (!_fileOperations.DirectoryExists(puzzleDirectoryPath))
            {
                throw new ArgumentException($"directory does not exist: {puzzleDirectoryPath}");
            }

            string[] puzzleFilePaths = _fileOperations.GetSortedDirectoryContents(puzzleDirectoryPath);

            if (puzzleFilePaths.Length == 0)
            {
                throw new ArgumentException($"puzzle directory contains no files: {puzzleDirectoryPath}");
            }

            if (puzzleFilePaths.Length > maximumNumberOfFiles)
            {
                Array.Resize(ref puzzleFilePaths, maximumNumberOfFiles);
            }

            return(puzzleFilePaths);
        }