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