public void ProjectFileReader_Bad_Project_File_Warns() { ConsoleLogger logger = new ConsoleLogger(); using (ProjectFileReader projectFileReader = new ProjectFileReader(logger)) { string badProjectPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".csproj"); File.WriteAllText(badProjectPath, "neener neener"); try { projectFileReader.LoadProject(badProjectPath); // Simulate the exception so we get the exact text string warningMessage = null; try { Engine engine = new Engine(); Project project = new Project(engine); project.Load(badProjectPath); } catch (InvalidProjectFileException ipfe) { warningMessage = string.Format(CultureInfo.CurrentCulture, Resource.Failed_To_Open_Project, badProjectPath, ipfe.Message); } TestHelper.AssertContainsWarnings(logger, new string[] { warningMessage }); } finally { File.Delete(badProjectPath); } } }
public void ProjectFileReader_Nonexistent_Project_File_Warns() { ConsoleLogger logger = new ConsoleLogger(); string badProjectPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".csproj"); using (ProjectFileReader projectFileReader = new ProjectFileReader(logger)) { try { projectFileReader.LoadProject(badProjectPath); string warningMessage = string.Format(CultureInfo.CurrentCulture, Resource.Project_Does_Not_Exist, badProjectPath); TestHelper.AssertContainsWarnings(logger, new string[] { warningMessage }); } finally { File.Delete(badProjectPath); } } }
public void ProjectFileReader_Nonexistent_Project_File_Warns() { ConsoleLogger logger = new ConsoleLogger(); string badProjectPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".csproj"); using (ProjectFileReader projectFileReader = new ProjectFileReader(logger)) { try { projectFileReader.LoadProject(badProjectPath); string warningMessage = string.Format(CultureInfo.CurrentCulture, Resource.Project_Does_Not_Exist, badProjectPath); TestHelper.AssertContainsWarnings(logger, new string[] { warningMessage }); } finally { File.Delete(badProjectPath); } } }
public void ProjectFileReader_Bad_Project_File_Warns() { ConsoleLogger logger = new ConsoleLogger(); using (ProjectFileReader projectFileReader = new ProjectFileReader(logger)) { string badProjectPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".csproj"); File.WriteAllText(badProjectPath, "neener neener"); try { projectFileReader.LoadProject(badProjectPath); // Simulate the exception so we get the exact text string warningMessage = TestHelper.GetFailedToOpenProjectMessage(badProjectPath); TestHelper.AssertContainsWarnings(logger, new string[] { warningMessage }); } finally { File.Delete(badProjectPath); } } }
public void ProjectFileReader_Bad_Project_File_Warns() { ConsoleLogger logger = new ConsoleLogger(); using (ProjectFileReader projectFileReader = new ProjectFileReader(logger)) { string badProjectPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".csproj"); File.WriteAllText(badProjectPath, "neener neener"); try { projectFileReader.LoadProject(badProjectPath); // Simulate the exception so we get the exact text string warningMessage = null; try { Engine engine = new Engine(); Project project = new Project(engine); project.Load(badProjectPath); } catch (InvalidProjectFileException ipfe) { warningMessage = string.Format(CultureInfo.CurrentCulture, Resource.Failed_To_Open_Project, badProjectPath, ipfe.Message); } TestHelper.AssertContainsWarnings(logger, new string[] { warningMessage }); } finally { File.Delete(badProjectPath); } } }