File: TestPackage.cs

package info (click to toggle)
mono 4.6.2.7+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 778,148 kB
  • ctags: 914,052
  • sloc: cs: 5,779,509; xml: 2,773,713; ansic: 432,645; sh: 14,749; makefile: 12,361; perl: 2,488; python: 1,434; cpp: 849; asm: 531; sql: 95; sed: 16; php: 1
file content (178 lines) | stat: -rw-r--r-- 4,640 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// ****************************************************************
// Copyright 2007, Charlie Poole
// This is free software licensed under the NUnit license. You may
// obtain a copy of the license at http://nunit.org/?p=license&r=2.4
// ****************************************************************
using System;
using System.IO;
using System.Collections;
using System.Collections.Specialized;

namespace NUnit.Core
{
	/// <summary>
	/// TestPackage holds information about a set of tests to
	/// be loaded by a TestRunner. It may represent a single
	/// assembly or a set of assemblies. It supports selection
	/// of a single test fixture for loading.
	/// </summary>
	[Serializable]
	public class TestPackage
	{
		private string name;
		private string fullName;

		private ListDictionary settings = new ListDictionary();

		private string basePath;
		private string configFile;
		private string binPath;
		private bool autoBinPath;

		private ArrayList assemblies;
		private string testName;
		private bool isSingleAssembly;


		/// <summary>
		/// Construct a package, specifying the name of the package.
		/// If the package name is an assembly file type (dll or exe)
		/// then the resulting package represents a single assembly.
		/// Otherwise it is a container for multiple assemblies.
		/// </summary>
		/// <param name="name">The name of the package</param>
		public TestPackage( string name )
		{
			this.fullName = name;
			this.name = Path.GetFileName( name );
			this.assemblies = new ArrayList();
			if ( IsAssemblyFileType( name ) )
			{
				this.isSingleAssembly = true;
				this.assemblies.Add( name );
			}
		}

		/// <summary>
		/// Construct a package, specifying the name to be used
		/// and a list of assemblies.
		/// </summary>
		/// <param name="name">The package name, used to name the top-level test node</param>
		/// <param name="assemblies">The list of assemblies comprising the package</param>
		public TestPackage( string name, IList assemblies )
		{
			this.fullName = name;
			this.name = Path.GetFileName( name );
			this.assemblies = new ArrayList( assemblies );
			this.isSingleAssembly = false;
		}

		/// <summary>
		/// Gets the name of the package
		/// </summary>
		public string Name
		{
			get { return name; }
		}

		/// <summary>
		/// Gets the full name of the package, which is usually
		/// the path to the NUnit project used to create the it
		/// </summary>
		public string FullName
		{
			get { return fullName; }
		}

		/// <summary>
		/// The BasePath to be used in loading the assemblies
		/// </summary>
		public string BasePath
		{
			get { return basePath; }
			set { basePath = value; }
		}

		/// <summary>
		/// The configuration file to be used
		/// </summary>
		public string ConfigurationFile
		{
			get { return configFile; }
			set { configFile = value; }
		}

		/// <summary>
		/// Addditional directories to be probed when loading assemblies
		/// </summary>
		public string PrivateBinPath
		{
			get { return binPath; }
			set { binPath = value; }
		}

		/// <summary>
		/// Indicates whether the probing path should be generated
		/// automatically based on the list of assemblies.
		/// </summary>
		public bool AutoBinPath
		{
			get { return autoBinPath; }
			set { autoBinPath = value; }
		}

		/// <summary>
		/// Assemblies to be loaded. At least one must be specified.
		/// </summary>
		public IList Assemblies
		{
			get { return assemblies; }
		}

		/// <summary>
		/// Return true if the package represents a single assembly.
		/// No root node is displayed in that case.
		/// </summary>
		public bool IsSingleAssembly
		{
			get { return isSingleAssembly; }
		}

		/// <summary>
		/// Fully qualified name of test to be loaded. If not 
		/// specified, all the tests in the assemblies are loaded.
		/// </summary>
		public string TestName
		{
			get { return testName; }
			set { testName = value; }
		}

		/// <summary>
		/// Gets the dictionary of settings for this TestPackage
		/// </summary>
		public IDictionary Settings
		{
			get { return settings; }
		}

		/// <summary>
		/// Return the value of a bool setting or a default.
		/// </summary>
		/// <param name="name">The name of the setting</param>
		/// <param name="defaultSetting">The default value</param>
		/// <returns></returns>
		public bool GetSetting( string name, bool defaultSetting )
		{
			object setting = settings[name];
			
			return setting == null ? defaultSetting : (bool)setting;
		}

		private static bool IsAssemblyFileType( string path )
		{
			string extension = Path.GetExtension( path ).ToLower();
			return extension == ".dll" || extension == ".exe";
		}
	}
}