public void GetFilesOfClass_PartialClassWith2Files_2FilesFound() { var files = classSearcher.GetFilesOfClass("Test.PartialClass"); Assert.IsNotNull(files, "Files must not be null."); Assert.IsTrue(files.Contains("C:\\temp\\PartialClass.cs"), "Files does not contain expected file"); Assert.IsTrue(files.Contains("C:\\temp\\PartialClass2.cs"), "Files does not contain expected file"); }
/// <summary> /// Tries to find file ids of class. /// </summary> /// <param name="classSearcher">The class searcher.</param> /// <param name="className">Name of the class.</param> /// <param name="filenameByFileIdDictionary">Dictionary containing all files used in the report by their corresponding id.</param> /// <param name="filesContainer">The files container.</param> /// <returns>The ids of the files the class is defined in.</returns> private IEnumerable <string> TryToFindFileIdsOfClass(ClassSearcher classSearcher, string className, Dictionary <string, string> filenameByFileIdDictionary, XContainer filesContainer) { IEnumerable <string> files = classSearcher.GetFilesOfClass(className.Replace("/", string.Empty)); var fileIds = new List <string>(); foreach (var file in files) { var existingFileId = filenameByFileIdDictionary.Where(kv => kv.Value == file).Select(kv => kv.Key).FirstOrDefault(); if (existingFileId != null) { fileIds.Add(existingFileId); } else { // Update dictionary string newFileId = this.currentFileId.ToString(CultureInfo.InvariantCulture); filenameByFileIdDictionary.Add(newFileId, file); fileIds.Add(newFileId); // Update report this.AddNewFile(filesContainer, newFileId, file); this.currentFileId--; } } return(fileIds); }