コード例 #1
0
        /// <summary>
        /// Scans the test file extracting all referenced files from it.
        /// </summary>
        /// <param name="referencedFiles">The list of referenced files</param>
        /// <param name="definition">Test framework defintition</param>
        /// <param name="textToParse">The content of the file to parse and extract from</param>
        /// <param name="currentFilePath">Path to the file under test</param>
        /// <param name="chutzpahTestSettings"></param>
        /// <returns></returns>
        public void GetReferencedFiles(List <ReferencedFile> referencedFiles, IFrameworkDefinition definition, ChutzpahTestSettingsFile chutzpahTestSettings)
        {
            var filesUnderTests = referencedFiles.Where(x => x.IsFileUnderTest).ToList();

            var referencePathSet = new HashSet <string>(referencedFiles.Select(x => x.Path), StringComparer.OrdinalIgnoreCase);

            // Process the references that the user specifies in the chutzpah settings file
            foreach (var reference in chutzpahTestSettings.References.Where(reference => reference != null))
            {
                // The path we assume default to the chuzpah.json directory if the Path property is not set
                var referencePath = string.IsNullOrEmpty(reference.Path) ? reference.SettingsFileDirectory : reference.Path;

                ProcessFilePathAsReference(
                    referencePathSet,
                    definition,
                    reference.SettingsFileDirectory,
                    chutzpahTestSettings,
                    referencePath,
                    referencedFiles,
                    new ReferencePathSettings(reference));
            }

            // Process the references defined using /// <reference comments in test file contents
            foreach (var fileUnderTest in filesUnderTests)
            {
                var testFileText = fileSystem.GetText(fileUnderTest.Path);

                definition.Process(fileUnderTest, testFileText, chutzpahTestSettings);

                if (fileUnderTest.ExpandReferenceComments)
                {
                    var result = GetReferencedFiles(
                        referencePathSet,
                        definition,
                        testFileText,
                        fileUnderTest.Path,
                        chutzpahTestSettings);


                    var flattenedReferenceTree = from root in result
                                                 from flattened in FlattenReferenceGraph(root)
                                                 select flattened;

                    referencedFiles.AddRange(flattenedReferenceTree);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Scans the test file extracting all referenced files from it.
        /// </summary>
        /// <param name="referencedFiles">The list of referenced files</param>
        /// <param name="definition">Test framework defintition</param>
        /// <param name="textToParse">The content of the file to parse and extract from</param>
        /// <param name="currentFilePath">Path to the file under test</param>
        /// <param name="chutzpahTestSettings"></param>
        /// <returns></returns>
        public void GetReferencedFiles(List<ReferencedFile> referencedFiles, IFrameworkDefinition definition, ChutzpahTestSettingsFile chutzpahTestSettings)
        {
            var filesUnderTests = referencedFiles.Where(x => x.IsFileUnderTest).ToList();

            var referencePathSet = new HashSet<string>(referencedFiles.Select(x => x.Path), StringComparer.OrdinalIgnoreCase);

            // Process the references that the user specifies in the chutzpah settings file
            foreach (var reference in chutzpahTestSettings.References.Where(reference => reference != null))
            {
                // The path we assume default to the chuzpah.json directory if the Path property is not set
                var referencePath = string.IsNullOrEmpty(reference.Path) ? reference.SettingsFileDirectory : reference.Path;

                ProcessFilePathAsReference(
                    referencePathSet,
                    definition,
                    reference.SettingsFileDirectory,
                    chutzpahTestSettings,
                    referencePath,
                    referencedFiles,
                    new ReferencePathSettings(reference));
            }

            // Process the references defined using /// <reference comments in test file contents
            foreach (var fileUnderTest in filesUnderTests)
            {
                var testFileText = fileSystem.GetText(fileUnderTest.Path);

                definition.Process(fileUnderTest, testFileText, chutzpahTestSettings);

                if (fileUnderTest.ExpandReferenceComments)
                {
                    var result = GetReferencedFiles(
                        referencePathSet,
                        definition,
                        testFileText,
                        fileUnderTest.Path,
                        chutzpahTestSettings);


                    var flattenedReferenceTree = from root in result
                                                 from flattened in FlattenReferenceGraph(root)
                                                 select flattened;

                    referencedFiles.AddRange(flattenedReferenceTree);
                }
            }
        }