/// <summary> /// Sets up a CodeProject for use during the test. /// </summary> /// <param name="testInfo">The test information.</param> /// <param name="console">The console which will run the test.</param> /// <param name="autoFix">Indicates whether the test is running in auto-fix mode.</param> /// <param name="copy">Indicates whether to create the file copy.</param> /// <param name="simulationFrameworkVersion">The framework version to simulate.</param> /// <returns> /// Returns the CodeProject. /// </returns> private static CodeProject PrepareCodeProjectForTest(TestInfo testInfo, StyleCopConsole console, bool autoFix, bool copy, double simulationFrameworkVersion) { // Create an empty configuration. Configuration configuration = new Configuration(null); // Create a CodeProject for the test file. CodeProject project = new CodeProject( "TheProject".GetHashCode(), Path.GetDirectoryName(testInfo.StyleCopSettingsFileLocation), configuration, simulationFrameworkVersion); // Add each source file to this project. foreach (TestCodeFileInfo sourceFile in testInfo.TestCodeFiles) { if (autoFix) { string autoFixFile = testInfo.AutoFixFileName(sourceFile.CodeFile); console.Core.Environment.AddSourceCode(project, autoFixFile, null); if (copy) { Directory.CreateDirectory(Path.GetDirectoryName(autoFixFile)); File.Copy(sourceFile.CodeFile, autoFixFile); } } else { console.Core.Environment.AddSourceCode(project, sourceFile.CodeFile, null); } } return project; }