public void GetFiles_EmptyDirectory_NoFilesFound() { Directory.CreateDirectory("tmp"); var files = GlobbingFileSearch.GetFiles(Path.Combine("tmp", "*")).ToArray(); Assert.Empty(files); Directory.Delete("tmp"); }
/// <summary> /// Initializes a new instance of the <see cref="ReportConfiguration" /> class. /// </summary> /// <param name="reportFilePatterns">The report file patterns.</param> /// <param name="targetDirectory">The target directory.</param> /// <param name="sourceDirectories">The source directories.</param> /// <param name="historyDirectory">The history directory.</param> /// <param name="reportTypes">The report types.</param> /// <param name="plugins">The plugins.</param> /// <param name="assemblyFilters">The assembly filters.</param> /// <param name="classFilters">The class filters.</param> /// <param name="fileFilters">The file filters.</param> /// <param name="verbosityLevel">The verbosity level.</param> /// <param name="tag">The custom tag (e.g. build number).</param> public ReportConfiguration( IEnumerable <string> reportFilePatterns, string targetDirectory, IEnumerable <string> sourceDirectories, string historyDirectory, IEnumerable <string> reportTypes, IEnumerable <string> plugins, IEnumerable <string> assemblyFilters, IEnumerable <string> classFilters, IEnumerable <string> fileFilters, string verbosityLevel, string tag) { if (reportFilePatterns == null) { throw new ArgumentNullException(nameof(reportFilePatterns)); } if (sourceDirectories == null) { throw new ArgumentNullException(nameof(sourceDirectories)); } if (reportTypes == null) { throw new ArgumentNullException(nameof(reportTypes)); } if (plugins == null) { throw new ArgumentNullException(nameof(plugins)); } if (assemblyFilters == null) { throw new ArgumentNullException(nameof(assemblyFilters)); } if (classFilters == null) { throw new ArgumentNullException(nameof(classFilters)); } if (fileFilters == null) { throw new ArgumentNullException(nameof(fileFilters)); } var seen = new HashSet <string>(); foreach (var reportFilePattern in reportFilePatterns) { try { var files = GlobbingFileSearch.GetFiles(reportFilePattern); if (files.Any()) { foreach (var file in files) { if (seen.Add(file)) { this.reportFiles.Add(file); } } } else { this.invalidReportFilePatterns.Add(reportFilePattern); } } catch (Exception) { this.invalidReportFilePatterns.Add(reportFilePattern); } } this.TargetDirectory = targetDirectory ?? throw new ArgumentNullException(nameof(targetDirectory)); this.HistoryDirectory = historyDirectory; this.SourceDirectories = sourceDirectories.ToList(); if (reportTypes.Any()) { this.ReportTypes = reportTypes.ToList(); } else { this.ReportTypes = new[] { "Html" }; } this.Plugins = plugins.ToList(); this.AssemblyFilters = assemblyFilters.ToList(); this.ClassFilters = classFilters.ToList(); this.FileFilters = fileFilters.ToList(); if (verbosityLevel != null) { VerbosityLevel parsedVerbosityLevel = VerbosityLevel.Info; this.VerbosityLevelValid = Enum.TryParse <VerbosityLevel>(verbosityLevel, true, out parsedVerbosityLevel); if (this.VerbosityLevelValid) { this.VerbosityLevel = parsedVerbosityLevel; } } else { this.VerbosityLevelValid = true; } this.Tag = tag; }
public void GetFiles_UncPath_NoFilesFound() { var files = GlobbingFileSearch.GetFiles(@"\\UncPath\DoesNotExist\*.xml").ToArray(); Assert.Empty(files); }
public void GetFiles_RelativePath_DllFound() { var files = GlobbingFileSearch.GetFiles("..\\*\\*.dll").ToArray(); Assert.Contains(files, f => f.EndsWith(this.GetType().Assembly.GetName().Name + ".dll", StringComparison.OrdinalIgnoreCase)); }
public void GetFiles_MultiDirectory_MatchingFilesFound() { var files = GlobbingFileSearch.GetFiles(Path.Combine(FileManager.GetFilesDirectory(), "CSharp", "*roject*", "*lyzer*.cs")).ToArray(); Assert.Single(files); }
public void GetFiles_MultiDirectory_AllFilesFound() { var files = GlobbingFileSearch.GetFiles(Path.Combine(FileManager.GetFilesDirectory(), "*", "*", "*")).ToArray(); Assert.True(files.Length >= 39); }
public void GetFiles_SingleDirectory_XmlFilesFound() { var files = GlobbingFileSearch.GetFiles(Path.Combine(FileManager.GetCSharpReportDirectory(), "*.xml")).ToArray(); Assert.Equal(20, files.Length); }