Exemplo n.º 1
0
        /// <summary>
        /// Searches the class files.
        /// </summary>
        private void SearchClassFiles()
        {
            if (!System.IO.Directory.Exists(this.Directory))
            {
                return;
            }

            Logger.DebugFormat("  " + Resources.IndexingClasses, new DirectoryInfo(this.Directory).FullName);

            foreach (var file in SafeDirectorySearcher.EnumerateFiles(this.Directory, "*.cs", SearchOption.AllDirectories))
            {
                foreach (var classInFile in SourceCodeAnalyzer.GetClassesInFile(file))
                {
                    HashSet <string> filesOfClass = null;

                    if (!this.filesByClassName.TryGetValue(classInFile, out filesOfClass))
                    {
                        filesOfClass = new HashSet <string>();
                        this.filesByClassName.Add(classInFile, filesOfClass);
                    }

                    filesOfClass.Add(file);
                }
            }
        }
Exemplo n.º 2
0
        public void GetClassesInFile_AllClassesAreReturned()
        {
            var classes = SourceCodeAnalyzer.GetClassesInFile(Path.Combine(FileManager.GetReportDirectory(), "TestClasses", "TestClass.cs"));

            Assert.IsNotNull(classes, "Classes must not be null.");
            Assert.IsTrue(classes.Contains("Test.TestClass"), "Classes does not contain root class");
            Assert.IsTrue(classes.Contains("Test.TestClassNestedClass"), "Classes does not contain nested class");
        }