/// <summary> /// Creates a project to wrap a list of assemblies /// </summary> public static NUnitProject FromAssemblies(string[] assemblies) { // if only one assembly is passed in then the configuration file // should follow the name of the assembly. This will only happen // if the LoadAssembly method is called. Currently the console ui // does not differentiate between having one or multiple assemblies // passed in. if (assemblies.Length == 1) { return(NUnitProject.FromAssembly(assemblies[0])); } NUnitProject project = NUnitProject.EmptyProject(); ProjectConfig config = new ProjectConfig("Default"); foreach (string assembly in assemblies) { string fullPath = Path.GetFullPath(assembly); if (!File.Exists(fullPath)) { throw new FileNotFoundException(string.Format("Assembly not found: {0}", fullPath)); } config.Assemblies.Add(fullPath); } project.Configs.Add(config); // TODO: Deduce application base, and provide a // better value for loadpath and project path // analagous to how new projects are handled string basePath = Path.GetDirectoryName(Path.GetFullPath(assemblies[0])); project.projectPath = Path.Combine(basePath, project.Name + ".nunit"); project.IsDirty = true; return(project); }
/// <summary> /// Return a test project by either loading it from /// the supplied path, creating one from a VS file /// or wrapping an assembly. /// </summary> public static NUnitProject LoadProject(string path) { if (NUnitProject.IsProjectFile(path)) { NUnitProject project = new NUnitProject(path); project.Load(); return(project); } else if (VSProject.IsProjectFile(path)) { return(NUnitProject.FromVSProject(path)); } else if (VSProject.IsSolutionFile(path)) { return(NUnitProject.FromVSSolution(path)); } else { return(NUnitProject.FromAssembly(path)); } }