/// <summary> /// Creates a project to wrap a list of assemblies /// </summary> public NUnitProject WrapAssemblies( 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 WrapAssembly(assemblies[0]); NUnitProject project = Services.ProjectService.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; }
public AssemblyListItem( ProjectConfig config, string path, bool hasTests ) { if ( !Path.IsPathRooted( path ) ) throw new ArgumentException( "Assembly path must be absolute" ); this.config = config; this.path = path; this.hasTests = hasTests; }
private void configComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { selectedConfig = project.Configs[(string)configComboBox.SelectedItem]; applicationBaseTextBox.Text = selectedConfig.RelativeBasePath; configFileTextBox.Text = selectedConfig.ConfigurationFile; switch ( selectedConfig.BinPathType ) { case BinPathType.Auto: autoBinPathRadioButton.Checked = true; break; case BinPathType.Manual: manualBinPathRadioButton.Checked = true; privateBinPathTextBox.Text = selectedConfig.PrivateBinPath; break; default: noBinPathRadioButton.Checked = true; break; } assemblyListBox_Populate(); }
public void SetActiveConfig( int index ) { activeConfig = configs[index]; HasChangesRequiringReload = IsDirty = true; }
public void SetActiveConfig( string name ) { foreach( ProjectConfig config in configs ) { if ( config.Name == name ) { activeConfig = config; HasChangesRequiringReload = IsDirty = true; break; } } }
public void SetActiveConfig(int index) { activeConfig = configs[index]; OnProjectChange(ProjectChangeType.ActiveConfig, activeConfig.Name); }
public bool Contains( ProjectConfig config ) { return InnerList.Contains( config ); }
public AssemblyList( ProjectConfig config ) { this.config = config; }
private void configComboBox_Populate() { configComboBox.Items.Clear(); if ( selectedConfig == null ) selectedConfig = project.ActiveConfig; int selectedIndex = -1; foreach( ProjectConfig config in project.Configs ) { string name = config.Name; int index = configComboBox.Items.Add( name ); if ( name == selectedConfig.Name ) selectedIndex = index; } if ( selectedIndex == -1 && configComboBox.Items.Count > 0 ) { selectedIndex = 0; selectedConfig = project.Configs[0]; } if ( selectedIndex == -1 ) selectedConfig = null; else configComboBox.SelectedIndex = selectedIndex; addAssemblyButton.Enabled = removeAssemblyButton.Enabled = project.Configs.Count > 0; }
public int IndexOf( ProjectConfig config ) { return InnerList.IndexOf( config ); }
/// <summary> /// Creates a project to wrap an assembly /// </summary> public static NUnitProject FromAssembly( string assemblyPath ) { if ( !File.Exists( assemblyPath ) ) throw new FileNotFoundException( string.Format( "Assembly not found: {0}", assemblyPath ) ); string fullPath = Path.GetFullPath( assemblyPath ); NUnitProject project = new NUnitProject( fullPath ); ProjectConfig config = new ProjectConfig( "Default" ); config.Assemblies.Add( fullPath ); project.Configs.Add( config ); project.isAssemblyWrapper = true; project.IsDirty = false; return project; }
protected override void OnRemoveComplete(int index, object obj) { ProjectConfig config = obj as ProjectConfig; this.project.OnProjectChange(ProjectChangeType.RemoveConfig, config.Name); }
protected override void OnInsertComplete(int index, object obj) { ProjectConfig config = obj as ProjectConfig; project.OnProjectChange(ProjectChangeType.AddConfig, config.Name); }
public bool Contains(ProjectConfig config) { return(InnerList.Contains(config)); }
public void Add(ProjectConfig config) { List.Add(config); config.Project = this.project; config.Changed += new EventHandler(config_Changed); }
private void config_Changed(object sender, EventArgs e) { ProjectConfig config = sender as ProjectConfig; project.OnProjectChange(ProjectChangeType.UpdateConfig, config.Name); }
private void okButton_Click(object sender, System.EventArgs e) { configurationName = configurationNameTextBox.Text; if ( configurationName == string.Empty ) { UserMessage.Display( "No configuration name provided", "Configuration Name Error" ); return; } if ( project.Configs.Contains( configurationName ) ) { // TODO: Need general error message display UserMessage.Display( "A configuration with that name already exists", "Configuration Name Error" ); return; } // ToDo: Move more of this to project ProjectConfig newConfig = new ProjectConfig( configurationName ); copyConfigurationName = null; if ( configurationComboBox.SelectedIndex > 0 ) { copyConfigurationName = (string)configurationComboBox.SelectedItem; ProjectConfig copyConfig = project.Configs[copyConfigurationName]; if ( copyConfig != null ) foreach( string assembly in copyConfig.Assemblies ) newConfig.Assemblies.Add( assembly ); } project.Configs.Add( newConfig ); DialogResult = DialogResult.OK; Close(); }
public void SetActiveConfig( int index ) { activeConfig = configs[index]; OnProjectChange( ProjectChangeType.ActiveConfig, activeConfig.Name ); }
public void Remove( ProjectConfig config ) { string name = config.Name; bool wasActive = name == this.Project.ActiveConfigName; List.Remove( config ); }
public void Load() { XmlTextReader reader = new XmlTextReader(projectPath); string activeConfigName = null; ProjectConfig currentConfig = null; try { reader.MoveToContent(); if (reader.NodeType != XmlNodeType.Element || reader.Name != "NUnitProject") { throw new ProjectFormatException( "Invalid project format: <NUnitProject> expected.", reader.LineNumber, reader.LinePosition); } while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "Settings": if (reader.NodeType == XmlNodeType.Element) { activeConfigName = reader.GetAttribute("activeconfig"); if (activeConfigName == "NUnitAutoConfig") { activeConfigName = NUnitFramework.BuildConfiguration; } string appbase = reader.GetAttribute("appbase"); if (appbase != null) { this.BasePath = appbase; } } break; case "Config": if (reader.NodeType == XmlNodeType.Element) { string configName = reader.GetAttribute("name"); currentConfig = new ProjectConfig(configName); currentConfig.BasePath = reader.GetAttribute("appbase"); currentConfig.ConfigurationFile = reader.GetAttribute("configfile"); string binpath = reader.GetAttribute("binpath"); currentConfig.PrivateBinPath = binpath; string type = reader.GetAttribute("binpathtype"); if (type == null) { if (binpath == null) { currentConfig.BinPathType = BinPathType.Auto; } else { currentConfig.BinPathType = BinPathType.Manual; } } else { currentConfig.BinPathType = (BinPathType)Enum.Parse(typeof(BinPathType), type, true); } Configs.Add(currentConfig); if (configName == activeConfigName) { activeConfig = currentConfig; } } else if (reader.NodeType == XmlNodeType.EndElement) { currentConfig = null; } break; case "assembly": if (reader.NodeType == XmlNodeType.Element && currentConfig != null) { string path = reader.GetAttribute("path"); currentConfig.Assemblies.Add( Path.Combine(currentConfig.BasePath, path)); } break; default: break; } } } this.IsDirty = false; } catch (FileNotFoundException) { throw; } catch (XmlException e) { throw new ProjectFormatException( string.Format("Invalid project format: {0}", e.Message), e.LineNumber, e.LinePosition); } catch (Exception e) { throw new ProjectFormatException( string.Format("Invalid project format: {0} Line {1}, Position {2}", e.Message, reader.LineNumber, reader.LinePosition), reader.LineNumber, reader.LinePosition); } finally { reader.Close(); } }
public void Load() { XmlTextReader reader = new XmlTextReader( projectPath ); string activeConfigName = null; ProjectConfig currentConfig = null; try { reader.MoveToContent(); if ( reader.NodeType != XmlNodeType.Element || reader.Name != "NUnitProject" ) throw new ProjectFormatException( "Invalid project format: <NUnitProject> expected.", reader.LineNumber, reader.LinePosition ); while( reader.Read() ) if ( reader.NodeType == XmlNodeType.Element ) switch( reader.Name ) { case "Settings": if ( reader.NodeType == XmlNodeType.Element ) { activeConfigName = reader.GetAttribute( "activeconfig" ); if (activeConfigName == "NUnitAutoConfig") activeConfigName = NUnitFramework.BuildConfiguration; string appbase = reader.GetAttribute( "appbase" ); if ( appbase != null ) this.BasePath = appbase; } break; case "Config": if ( reader.NodeType == XmlNodeType.Element ) { string configName = reader.GetAttribute( "name" ); currentConfig = new ProjectConfig( configName ); currentConfig.BasePath = reader.GetAttribute( "appbase" ); currentConfig.ConfigurationFile = reader.GetAttribute( "configfile" ); string binpath = reader.GetAttribute( "binpath" ); currentConfig.PrivateBinPath = binpath; string type = reader.GetAttribute( "binpathtype" ); if ( type == null ) if ( binpath == null ) currentConfig.BinPathType = BinPathType.Auto; else currentConfig.BinPathType = BinPathType.Manual; else currentConfig.BinPathType = (BinPathType)Enum.Parse( typeof( BinPathType ), type, true ); Configs.Add( currentConfig ); if ( configName == activeConfigName ) activeConfig = currentConfig; } else if ( reader.NodeType == XmlNodeType.EndElement ) currentConfig = null; break; case "assembly": if ( reader.NodeType == XmlNodeType.Element && currentConfig != null ) { string path = reader.GetAttribute( "path" ); currentConfig.Assemblies.Add( Path.Combine( currentConfig.BasePath, path ) ); } break; default: break; } this.IsDirty = false; } catch( FileNotFoundException ) { throw; } catch( XmlException e ) { throw new ProjectFormatException( string.Format( "Invalid project format: {0}", e.Message ), e.LineNumber, e.LinePosition ); } catch( Exception e ) { throw new ProjectFormatException( string.Format( "Invalid project format: {0} Line {1}, Position {2}", e.Message, reader.LineNumber, reader.LinePosition ), reader.LineNumber, reader.LinePosition ); } finally { reader.Close(); } }
public void Add( ProjectConfig config ) { List.Add( config ); config.Project = this.project; }
public void SetActiveConfig( string name ) { foreach( ProjectConfig config in configs ) { if ( config.Name == name ) { activeConfig = config; OnProjectChange( ProjectChangeType.ActiveConfig, activeConfig.Name ); break; } } }
public void Add( ProjectConfig config ) { List.Add( config ); config.Project = this.project; config.Changed += new EventHandler(config_Changed); }
private void configComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { selectedConfig = project.Configs[(string)configComboBox.SelectedItem]; RuntimeFramework framework = selectedConfig.RuntimeFramework; RuntimeType runtime = RuntimeType.Any; Version version = RuntimeFramework.DefaultVersion; if (framework != null) { runtime = framework.Runtime; version = framework.ClrVersion; } int index = runtimeComboBox.FindStringExact(runtime.ToString(), 0); if ( index < 0 ) index = 0; runtimeComboBox.SelectedIndex = index; if (framework == null || framework.AllowAnyVersion) runtimeVersionComboBox.SelectedIndex = 0; else runtimeVersionComboBox.Text = version.ToString(); applicationBaseTextBox.Text = selectedConfig.RelativeBasePath; configFileTextBox.Text = selectedConfig.ConfigurationFile; switch ( selectedConfig.BinPathType ) { case BinPathType.Auto: autoBinPathRadioButton.Checked = true; break; case BinPathType.Manual: manualBinPathRadioButton.Checked = true; privateBinPathTextBox.Text = selectedConfig.PrivateBinPath; break; default: noBinPathRadioButton.Checked = true; break; } assemblyListBox_Populate(); }
public void SetActiveConfig(int index) { activeConfig = configs[index]; HasChangesRequiringReload = IsDirty = true; }