Exemplo n.º 1
0
        public static void InsertMeasurementCode(
            DirectoryInfo rootDir, ICollection <FileInfo> fileInfos, DirectoryInfo testDir,
            DirectoryInfo libDir, LanguageSupport mode, RecordingMode recordingMode)
        {
            Contract.Requires <ArgumentException>(rootDir.Exists);
            Contract.Requires <ArgumentException>(testDir == null || testDir.Exists);
            Contract.Requires <ArgumentException>(libDir.Exists);
            Contract.Requires <ArgumentNullException>(mode != null);

            //root
            var covInfo = new CoverageInfo(rootDir.FullName, mode.Name, SharingMethod.File);
            //(o)root or src?
            var testInfo = testDir != null
                                        ? new TestInfo(rootDir.FullName)
                                        : null;

            //root
            RemoveExistingCoverageDataFiles(rootDir, libDir);

            mode.RemoveLibraries(libDir);
            //+src
            WriteProductionCodeFiles(rootDir, fileInfos, mode, covInfo);
            if (testInfo != null)
            {
                //(o)root or src
                WriteTestCodeFiles(rootDir, testDir, mode, testInfo);
            }
            else
            {
                // Initialize test information with empty contents
                testInfo = new TestInfo(rootDir.FullName);
                testInfo.TestCases.Add(new TestCase("nothing", "nothing", new CodeRange()));
            }
            //root
            WriteInfoFiles(rootDir, covInfo, testInfo);

            mode.CopyLibraries(libDir, recordingMode);
        }