1 // ****************************************************************
\r
2 // This is free software licensed under the NUnit license. You
\r
3 // may obtain a copy of the license as well as information regarding
\r
4 // copyright ownership at http://nunit.org/?p=license&r=2.4.
\r
5 // ****************************************************************
\r
9 using System.Collections;
\r
13 namespace NUnit.Util
\r
15 public enum BinPathType
\r
22 public class ProjectConfig
\r
24 #region Instance Variables
\r
27 /// The name of this config
\r
29 private string name;
\r
32 /// IProject interface of containing project
\r
34 protected NUnitProject project = null;
\r
37 /// List of the names of the assemblies
\r
39 private AssemblyList assemblies;
\r
42 /// Base path specific to this configuration
\r
44 private string basePath;
\r
47 /// Our configuration file, if specified
\r
49 private string configFile;
\r
52 /// Private bin path, if specified
\r
54 private string binPath;
\r
57 /// True if assembly paths should be added to bin path
\r
59 private BinPathType binPathType = BinPathType.Auto;
\r
64 public ProjectConfig( string name )
\r
67 this.assemblies = new AssemblyList();
\r
68 assemblies.Changed += new EventHandler( assemblies_Changed );
\r
72 #region Properties and Events
\r
74 public event EventHandler Changed;
\r
76 public NUnitProject Project
\r
78 // get { return project; }
\r
79 set { project = value; }
\r
84 get { return name; }
\r
87 if ( name != value )
\r
95 private bool BasePathSpecified
\r
99 return project.BasePathSpecified || this.basePath != null && this.basePath != "";
\r
104 /// The base directory for this config - used
\r
105 /// as the application base for loading tests.
\r
107 public string BasePath
\r
111 if ( project == null || project.BasePath == null )
\r
114 if ( basePath == null )
\r
115 return project.BasePath;
\r
117 return Path.Combine( project.BasePath, basePath );
\r
121 if ( BasePath != value )
\r
124 FireChangedEvent();
\r
130 /// The base path relative to the project base
\r
132 public string RelativeBasePath
\r
136 if ( project == null || basePath == null || !Path.IsPathRooted( basePath ) )
\r
139 return PathUtils.RelativePath( project.BasePath, basePath );
\r
143 private bool ConfigurationFileSpecified
\r
145 get { return configFile != null; }
\r
148 public string ConfigurationFile
\r
152 return configFile == null && project != null
\r
153 ? project.ConfigurationFile
\r
158 if ( ConfigurationFile != value )
\r
160 configFile = value;
\r
161 FireChangedEvent();
\r
166 public string ConfigurationFilePath
\r
170 return BasePath != null && ConfigurationFile != null
\r
171 ? Path.Combine( BasePath, ConfigurationFile )
\r
172 : ConfigurationFile;
\r
176 private bool PrivateBinPathSpecified
\r
178 get { return binPath != null; }
\r
182 /// The Path.PathSeparator-separated path containing all the
\r
183 /// assemblies in the list.
\r
185 public string PrivateBinPath
\r
187 get { return binPath; }
\r
190 if ( binPath != value )
\r
193 binPathType = binPath == null ? BinPathType.Auto : BinPathType.Manual;
\r
194 FireChangedEvent();
\r
200 /// How our PrivateBinPath is generated
\r
202 public BinPathType BinPathType
\r
204 get { return binPathType; }
\r
207 if ( binPathType != value )
\r
209 binPathType = value;
\r
210 FireChangedEvent();
\r
216 /// Return our AssemblyList
\r
218 public AssemblyList Assemblies
\r
220 get { return assemblies; }
\r
224 public TestPackage MakeTestPackage()
\r
226 TestPackage package = new TestPackage( project.ProjectPath );
\r
228 if ( !project.IsAssemblyWrapper )
\r
229 foreach ( string assembly in this.Assemblies )
\r
230 package.Assemblies.Add( assembly );
\r
232 if ( this.BasePathSpecified || this.PrivateBinPathSpecified || this.ConfigurationFileSpecified )
\r
234 package.BasePath = this.BasePath;
\r
235 package.PrivateBinPath = this.PrivateBinPath;
\r
236 package.ConfigurationFile = this.ConfigurationFile;
\r
239 package.AutoBinPath = this.BinPathType == BinPathType.Auto;
\r
244 private void assemblies_Changed( object sender, EventArgs e )
\r
246 FireChangedEvent();
\r
249 private void FireChangedEvent()
\r
251 if ( Changed != null )
\r
252 Changed( this, EventArgs.Empty );
\r