public void SaveProject() { if (Path.IsPathRooted(loader.TestProject.ProjectPath) && NUnitProject.IsProjectFile(loader.TestProject.ProjectPath)) { loader.TestProject.Save(); } else { SaveProjectAs(); } }
public static void SaveProject(Form owner) { TestLoader loader = Services.TestLoader; if (Path.IsPathRooted(loader.TestProject.ProjectPath) && NUnitProject.IsProjectFile(loader.TestProject.ProjectPath) && CanWriteProjectFile(loader.TestProject.ProjectPath)) { loader.TestProject.Save(); } else { SaveProjectAs(owner); } }
/// <summary> /// Helper method to determine if an IDataObject is valid /// for dropping on the tree view. It must be a the drop /// of a single file with a valid assembly file type. /// </summary> /// <param name="data">IDataObject to be tested</param> /// <returns>True if dropping is allowed</returns> private bool IsValidFileDrop(IDataObject data) { if (!data.GetDataPresent(DataFormats.FileDrop)) { return(false); } string [] fileNames = data.GetData(DataFormats.FileDrop) as string []; if (fileNames == null || fileNames.Length == 0) { return(false); } // We can't open more than one project at a time if (fileNames.Length == 1) { if (NUnitProject.IsProjectFile(fileNames[0])) { return(true); } if (UserSettings.Options.VisualStudioSupport) { if (VSProject.IsProjectFile(fileNames[0]) || VSProject.IsSolutionFile(fileNames[0])) { return(true); } } } // Multiple assemblies are allowed - we // assume they are all in the same directory // since they are being dragged together. foreach (string fileName in fileNames) { if (!ProjectPath.IsAssemblyFileType(fileName)) { return(false); } } return(true); }
/// <summary> /// Helper method to determine if an IDataObject is valid /// for dropping on the tree view. It must be a the drop /// of a single file with a valid assembly file type. /// </summary> /// <param name="data">IDataObject to be tested</param> /// <returns>True if dropping is allowed</returns> private bool IsValidFileDrop(IDataObject data) { if (!data.GetDataPresent(DataFormats.FileDrop)) { return(false); } string [] fileNames = data.GetData(DataFormats.FileDrop) as string []; if (fileNames == null || fileNames.Length == 0) { return(false); } // We can't open more than one project at a time // so handle length of 1 separately. if (fileNames.Length == 1) { string fileName = fileNames[0]; bool isProject = Services.UserSettings.GetSetting("Options.TestLoader.VisualStudioSupport", false) ? NUnitProject.CanLoadAsProject(fileName) : NUnitProject.IsProjectFile(fileName); return(isProject || PathUtils.IsAssemblyFileType(fileName)); } // Multiple assemblies are allowed - we // assume they are all in the same directory // since they are being dragged together. foreach (string fileName in fileNames) { if (!PathUtils.IsAssemblyFileType(fileName)) { return(false); } } return(true); }
public void IsProjectFile() { Assert.IsTrue(NUnitProject.IsProjectFile(@"\x\y\test.nunit")); Assert.IsFalse(NUnitProject.IsProjectFile(@"\x\y\test.junit")); }