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.
5
// ****************************************************************
9
using System.Collections;
10
using NUnit.Framework;
12
namespace NUnit.Util.Tests
15
/// Summary description for ProjectConfigTests.
18
public class ProjectConfigTests
20
private ProjectConfig activeConfig;
21
private ProjectConfig inactiveConfig;
22
private NUnitProject project;
27
activeConfig = new ProjectConfig( "Debug" );
28
inactiveConfig = new ProjectConfig("Release");
29
project = new NUnitProject( TestPath( "/test/myproject.nunit" ) );
30
project.Configs.Add( activeConfig );
31
project.Configs.Add(inactiveConfig);
32
project.IsDirty = false;
33
project.HasChangesRequiringReload = false;
37
/// Take a valid Linux filePath and make a valid windows filePath out of it
38
/// if we are on Windows. Change slashes to backslashes and, if the
39
/// filePath starts with a slash, add C: in front of it.
41
private string TestPath(string path)
43
if (Path.DirectorySeparatorChar != '/')
45
path = path.Replace('/', Path.DirectorySeparatorChar);
46
if (path[0] == Path.DirectorySeparatorChar)
54
public void EmptyConfig()
56
Assert.AreEqual( "Debug", activeConfig.Name );
57
Assert.AreEqual( 0, activeConfig.Assemblies.Count );
61
public void CanAddAssemblies()
63
string path1 = TestPath("/test/assembly1.dll");
64
string path2 = TestPath("/test/assembly2.dll");
65
activeConfig.Assemblies.Add(path1);
66
activeConfig.Assemblies.Add( path2 );
67
Assert.AreEqual( 2, activeConfig.Assemblies.Count );
68
Assert.AreEqual( path1, activeConfig.Assemblies[0] );
69
Assert.AreEqual( path2, activeConfig.Assemblies[1] );
75
string path1 = TestPath("/test/assembly1.dll");
76
string path2 = TestPath("/test/assembly2.dll");
77
activeConfig.Assemblies.Add( path1 );
78
activeConfig.Assemblies.Add( path2 );
80
string[] files = activeConfig.Assemblies.ToArray();
81
Assert.AreEqual( path1, files[0] );
82
Assert.AreEqual( path2, files[1] );
86
public void AddToActiveConfigMarksProjectDirty()
88
activeConfig.Assemblies.Add(TestPath("/test/bin/debug/assembly1.dll"));
89
Assert.IsTrue(project.IsDirty);
93
public void AddToActiveConfigRequiresReload()
95
activeConfig.Assemblies.Add(TestPath("/test/bin/debug/assembly1.dll"));
96
Assert.IsTrue(project.HasChangesRequiringReload);
100
public void AddToInactiveConfigMarksProjectDirty()
102
inactiveConfig.Assemblies.Add(TestPath("/test/bin/release/assembly1.dll"));
103
Assert.IsTrue(project.IsDirty);
107
public void AddToInactiveConfigDoesNotRequireReload()
109
inactiveConfig.Assemblies.Add(TestPath("/test/bin/release/assembly1.dll"));
110
Assert.IsFalse(project.HasChangesRequiringReload);
114
public void AddingConfigMarksProjectDirty()
116
project.Configs.Add("New");
117
Assert.IsTrue(project.IsDirty);
121
public void AddingInitialConfigRequiresReload()
123
NUnitProject newProj = new NUnitProject("/junk");
124
newProj.HasChangesRequiringReload = false;
125
newProj.Configs.Add("New");
126
Assert.That(newProj.HasChangesRequiringReload);
130
public void AddingSubsequentConfigDoesNotRequireReload()
132
project.Configs.Add("New");
133
Assert.IsFalse(project.HasChangesRequiringReload);
137
public void RenameActiveConfigMarksProjectDirty()
139
activeConfig.Name = "Renamed";
140
Assert.IsTrue(project.IsDirty);
144
public void RenameActiveConfigRequiresReload()
146
activeConfig.Name = "Renamed";
147
Assert.IsTrue(project.HasChangesRequiringReload);
151
public void RenameInctiveConfigMarksProjectDirty()
153
inactiveConfig.Name = "Renamed";
154
Assert.IsTrue(project.IsDirty);
158
public void RenameInactiveConfigDoesNotRequireReload()
160
inactiveConfig.Name = "Renamed";
161
Assert.IsFalse(project.HasChangesRequiringReload);
165
public void RemoveActiveConfigMarksProjectDirty()
167
string path1 = TestPath("/test/bin/debug/assembly1.dll");
168
activeConfig.Assemblies.Add(path1);
169
project.IsDirty = false;
170
activeConfig.Assemblies.Remove(path1);
171
Assert.IsTrue(project.IsDirty);
175
public void RemoveActiveConfigRequiresReload()
177
string path1 = TestPath("/test/bin/debug/assembly1.dll");
178
activeConfig.Assemblies.Add(path1);
179
project.IsDirty = false;
180
activeConfig.Assemblies.Remove(path1);
181
Assert.IsTrue(project.HasChangesRequiringReload);
185
public void RemoveInactiveConfigMarksProjectDirty()
187
string path1 = TestPath("/test/bin/debug/assembly1.dll");
188
inactiveConfig.Assemblies.Add(path1);
189
project.IsDirty = false;
190
inactiveConfig.Assemblies.Remove(path1);
191
Assert.IsTrue(project.IsDirty);
195
public void RemoveInactiveConfigDoesNotRequireReload()
197
string path1 = TestPath("/test/bin/debug/assembly1.dll");
198
inactiveConfig.Assemblies.Add(path1);
199
project.HasChangesRequiringReload = false;
200
inactiveConfig.Assemblies.Remove(path1);
201
Assert.IsFalse(project.HasChangesRequiringReload);
205
public void SettingActiveConfigApplicationBaseMarksProjectDirty()
207
activeConfig.BasePath = TestPath("/junk");
208
Assert.IsTrue(project.IsDirty);
212
public void SettingActiveConfigApplicationBaseRequiresReload()
214
activeConfig.BasePath = TestPath("/junk");
215
Assert.IsTrue(project.HasChangesRequiringReload);
219
public void SettingInactiveConfigApplicationBaseMarksProjectDirty()
221
inactiveConfig.BasePath = TestPath("/junk");
222
Assert.IsTrue(project.IsDirty);
226
public void SettingInactiveConfigApplicationBaseDoesNotRequireReload()
228
inactiveConfig.BasePath = TestPath("/junk");
229
Assert.IsFalse(project.HasChangesRequiringReload);
233
public void AbsoluteBasePath()
235
activeConfig.BasePath = TestPath("/junk");
236
string path1 = TestPath( "/junk/bin/debug/assembly1.dll" );
237
activeConfig.Assemblies.Add( path1 );
238
Assert.AreEqual( path1, activeConfig.Assemblies[0] );
242
public void RelativeBasePath()
244
activeConfig.BasePath = @"junk";
245
string path1 = TestPath("/test/junk/bin/debug/assembly1.dll");
246
activeConfig.Assemblies.Add( path1 );
247
Assert.AreEqual( path1, activeConfig.Assemblies[0] );
251
public void NoBasePathSet()
253
string path1 = TestPath( "/test/bin/debug/assembly1.dll" );
254
activeConfig.Assemblies.Add( path1 );
255
Assert.AreEqual( path1, activeConfig.Assemblies[0] );
259
public void SettingActiveConfigConfigurationFileMarksProjectDirty()
261
activeConfig.ConfigurationFile = "MyProject.config";
262
Assert.IsTrue(project.IsDirty);
266
public void SettingActiveConfigConfigurationFileRequiresReload()
268
activeConfig.ConfigurationFile = "MyProject.config";
269
Assert.IsTrue(project.HasChangesRequiringReload);
273
public void SettingInactiveConfigConfigurationFileMarksProjectDirty()
275
inactiveConfig.ConfigurationFile = "MyProject.config";
276
Assert.IsTrue(project.IsDirty);
280
public void SettingInactiveConfigConfigurationFileDoesNotRequireReload()
282
inactiveConfig.ConfigurationFile = "MyProject.config";
283
Assert.IsFalse(project.HasChangesRequiringReload);
287
public void DefaultConfigurationFile()
289
Assert.AreEqual( "myproject.config", activeConfig.ConfigurationFile );
290
Assert.AreEqual( TestPath( "/test/myproject.config" ), activeConfig.ConfigurationFilePath );
294
public void AbsoluteConfigurationFile()
296
string path1 = TestPath("/configs/myconfig.config");
297
activeConfig.ConfigurationFile = path1;
298
Assert.AreEqual( path1, activeConfig.ConfigurationFilePath );
302
public void RelativeConfigurationFile()
304
activeConfig.ConfigurationFile = "myconfig.config";
305
Assert.AreEqual( TestPath( "/test/myconfig.config" ), activeConfig.ConfigurationFilePath );
309
public void SettingActiveConfigPrivateBinPathMarksProjectDirty()
311
activeConfig.PrivateBinPath = TestPath("/junk") + Path.PathSeparator + TestPath("/bin");
312
Assert.IsTrue(project.IsDirty);
316
public void SettingActiveConfigPrivateBinPathRequiresReload()
318
activeConfig.PrivateBinPath = TestPath("/junk") + Path.PathSeparator + TestPath("/bin");
319
Assert.IsTrue(project.HasChangesRequiringReload);
323
public void SettingInactiveConfigPrivateBinPathMarksProjectDirty()
325
inactiveConfig.PrivateBinPath = TestPath("/junk") + Path.PathSeparator + TestPath("/bin");
326
Assert.IsTrue(project.IsDirty);
330
public void SettingInactiveConfigPrivateBinPathDoesNotRequireReload()
332
inactiveConfig.PrivateBinPath = TestPath("/junk") + Path.PathSeparator + TestPath("/bin");
333
Assert.IsFalse(project.HasChangesRequiringReload);
337
public void SettingActiveConfigBinPathTypeMarksProjectDirty()
339
activeConfig.BinPathType = BinPathType.Manual;
340
Assert.IsTrue(project.IsDirty);
344
public void SettingActiveConfigBinPathTypeRequiresReload()
346
activeConfig.BinPathType = BinPathType.Manual;
347
Assert.IsTrue(project.HasChangesRequiringReload);
351
public void SettingInactiveConfigBinPathTypeMarksProjectDirty()
353
inactiveConfig.BinPathType = BinPathType.Manual;
354
Assert.IsTrue(project.IsDirty);
358
public void SettingInactiveConfigBinPathTypeDoesNotRequireReload()
360
inactiveConfig.BinPathType = BinPathType.Manual;
361
Assert.IsFalse(project.HasChangesRequiringReload);
365
public void NoPrivateBinPath()
367
activeConfig.Assemblies.Add( TestPath( "/bin/assembly1.dll" ) );
368
activeConfig.Assemblies.Add( TestPath( "/bin/assembly2.dll" ) );
369
activeConfig.BinPathType = BinPathType.None;
370
Assert.IsNull( activeConfig.PrivateBinPath );
374
public void ManualPrivateBinPath()
376
activeConfig.Assemblies.Add( TestPath( "/test/bin/assembly1.dll" ) );
377
activeConfig.Assemblies.Add( TestPath( "/test/bin/assembly2.dll" ) );
378
activeConfig.BinPathType = BinPathType.Manual;
379
activeConfig.PrivateBinPath = TestPath( "/test" );
380
Assert.AreEqual( TestPath( "/test" ), activeConfig.PrivateBinPath );
383
// TODO: Move to DomainManagerTests
385
// public void AutoPrivateBinPath()
387
// config.Assemblies.Add( TestPath( "/test/bin/assembly1.dll" ) );
388
// config.Assemblies.Add( TestPath( "/test/bin/assembly2.dll" ) );
389
// config.BinPathType = BinPathType.Auto;
390
// Assert.AreEqual( "bin", config.PrivateBinPath );
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.
5
// ****************************************************************
9
using System.Collections;
10
using NUnit.Framework;
12
namespace NUnit.Util.Tests
15
/// Summary description for ProjectConfigTests.
18
public class ProjectConfigTests
20
private ProjectConfig activeConfig;
21
private ProjectConfig inactiveConfig;
22
private NUnitProject project;
27
activeConfig = new ProjectConfig( "Debug" );
28
inactiveConfig = new ProjectConfig("Release");
29
project = new NUnitProject( TestPath( "/test/myproject.nunit" ) );
30
project.Configs.Add( activeConfig );
31
project.Configs.Add(inactiveConfig);
32
project.IsDirty = false;
33
project.HasChangesRequiringReload = false;
37
/// Take a valid Linux filePath and make a valid windows filePath out of it
38
/// if we are on Windows. Change slashes to backslashes and, if the
39
/// filePath starts with a slash, add C: in front of it.
41
private string TestPath(string path)
43
if (Path.DirectorySeparatorChar != '/')
45
path = path.Replace('/', Path.DirectorySeparatorChar);
46
if (path[0] == Path.DirectorySeparatorChar)
54
public void EmptyConfig()
56
Assert.AreEqual( "Debug", activeConfig.Name );
57
Assert.AreEqual( 0, activeConfig.Assemblies.Count );
61
public void CanAddAssemblies()
63
string path1 = TestPath("/test/assembly1.dll");
64
string path2 = TestPath("/test/assembly2.dll");
65
activeConfig.Assemblies.Add(path1);
66
activeConfig.Assemblies.Add( path2 );
67
Assert.AreEqual( 2, activeConfig.Assemblies.Count );
68
Assert.AreEqual( path1, activeConfig.Assemblies[0] );
69
Assert.AreEqual( path2, activeConfig.Assemblies[1] );
75
string path1 = TestPath("/test/assembly1.dll");
76
string path2 = TestPath("/test/assembly2.dll");
77
activeConfig.Assemblies.Add( path1 );
78
activeConfig.Assemblies.Add( path2 );
80
string[] files = activeConfig.Assemblies.ToArray();
81
Assert.AreEqual( path1, files[0] );
82
Assert.AreEqual( path2, files[1] );
86
public void AddToActiveConfigMarksProjectDirty()
88
activeConfig.Assemblies.Add(TestPath("/test/bin/debug/assembly1.dll"));
89
Assert.IsTrue(project.IsDirty);
93
public void AddToActiveConfigRequiresReload()
95
activeConfig.Assemblies.Add(TestPath("/test/bin/debug/assembly1.dll"));
96
Assert.IsTrue(project.HasChangesRequiringReload);
100
public void AddToInactiveConfigMarksProjectDirty()
102
inactiveConfig.Assemblies.Add(TestPath("/test/bin/release/assembly1.dll"));
103
Assert.IsTrue(project.IsDirty);
107
public void AddToInactiveConfigDoesNotRequireReload()
109
inactiveConfig.Assemblies.Add(TestPath("/test/bin/release/assembly1.dll"));
110
Assert.IsFalse(project.HasChangesRequiringReload);
114
public void AddingConfigMarksProjectDirty()
116
project.Configs.Add("New");
117
Assert.IsTrue(project.IsDirty);
121
public void AddingInitialConfigRequiresReload()
123
NUnitProject newProj = new NUnitProject("/junk");
124
newProj.HasChangesRequiringReload = false;
125
newProj.Configs.Add("New");
126
Assert.That(newProj.HasChangesRequiringReload);
130
public void AddingSubsequentConfigDoesNotRequireReload()
132
project.Configs.Add("New");
133
Assert.IsFalse(project.HasChangesRequiringReload);
137
public void RenameActiveConfigMarksProjectDirty()
139
activeConfig.Name = "Renamed";
140
Assert.IsTrue(project.IsDirty);
144
public void RenameActiveConfigRequiresReload()
146
activeConfig.Name = "Renamed";
147
Assert.IsTrue(project.HasChangesRequiringReload);
151
public void RenameInctiveConfigMarksProjectDirty()
153
inactiveConfig.Name = "Renamed";
154
Assert.IsTrue(project.IsDirty);
158
public void RenameInactiveConfigDoesNotRequireReload()
160
inactiveConfig.Name = "Renamed";
161
Assert.IsFalse(project.HasChangesRequiringReload);
165
public void RemoveActiveConfigMarksProjectDirty()
167
string path1 = TestPath("/test/bin/debug/assembly1.dll");
168
activeConfig.Assemblies.Add(path1);
169
project.IsDirty = false;
170
activeConfig.Assemblies.Remove(path1);
171
Assert.IsTrue(project.IsDirty);
175
public void RemoveActiveConfigRequiresReload()
177
string path1 = TestPath("/test/bin/debug/assembly1.dll");
178
activeConfig.Assemblies.Add(path1);
179
project.IsDirty = false;
180
activeConfig.Assemblies.Remove(path1);
181
Assert.IsTrue(project.HasChangesRequiringReload);
185
public void RemoveInactiveConfigMarksProjectDirty()
187
string path1 = TestPath("/test/bin/debug/assembly1.dll");
188
inactiveConfig.Assemblies.Add(path1);
189
project.IsDirty = false;
190
inactiveConfig.Assemblies.Remove(path1);
191
Assert.IsTrue(project.IsDirty);
195
public void RemoveInactiveConfigDoesNotRequireReload()
197
string path1 = TestPath("/test/bin/debug/assembly1.dll");
198
inactiveConfig.Assemblies.Add(path1);
199
project.HasChangesRequiringReload = false;
200
inactiveConfig.Assemblies.Remove(path1);
201
Assert.IsFalse(project.HasChangesRequiringReload);
205
public void SettingActiveConfigApplicationBaseMarksProjectDirty()
207
activeConfig.BasePath = TestPath("/junk");
208
Assert.IsTrue(project.IsDirty);
212
public void SettingActiveConfigApplicationBaseRequiresReload()
214
activeConfig.BasePath = TestPath("/junk");
215
Assert.IsTrue(project.HasChangesRequiringReload);
219
public void SettingInactiveConfigApplicationBaseMarksProjectDirty()
221
inactiveConfig.BasePath = TestPath("/junk");
222
Assert.IsTrue(project.IsDirty);
226
public void SettingInactiveConfigApplicationBaseDoesNotRequireReload()
228
inactiveConfig.BasePath = TestPath("/junk");
229
Assert.IsFalse(project.HasChangesRequiringReload);
233
public void AbsoluteBasePath()
235
activeConfig.BasePath = TestPath("/junk");
236
string path1 = TestPath( "/junk/bin/debug/assembly1.dll" );
237
activeConfig.Assemblies.Add( path1 );
238
Assert.AreEqual( path1, activeConfig.Assemblies[0] );
242
public void RelativeBasePath()
244
activeConfig.BasePath = @"junk";
245
string path1 = TestPath("/test/junk/bin/debug/assembly1.dll");
246
activeConfig.Assemblies.Add( path1 );
247
Assert.AreEqual( path1, activeConfig.Assemblies[0] );
251
public void NoBasePathSet()
253
string path1 = TestPath( "/test/bin/debug/assembly1.dll" );
254
activeConfig.Assemblies.Add( path1 );
255
Assert.AreEqual( path1, activeConfig.Assemblies[0] );
259
public void SettingActiveConfigConfigurationFileMarksProjectDirty()
261
activeConfig.ConfigurationFile = "MyProject.config";
262
Assert.IsTrue(project.IsDirty);
266
public void SettingActiveConfigConfigurationFileRequiresReload()
268
activeConfig.ConfigurationFile = "MyProject.config";
269
Assert.IsTrue(project.HasChangesRequiringReload);
273
public void SettingInactiveConfigConfigurationFileMarksProjectDirty()
275
inactiveConfig.ConfigurationFile = "MyProject.config";
276
Assert.IsTrue(project.IsDirty);
280
public void SettingInactiveConfigConfigurationFileDoesNotRequireReload()
282
inactiveConfig.ConfigurationFile = "MyProject.config";
283
Assert.IsFalse(project.HasChangesRequiringReload);
287
public void DefaultConfigurationFile()
289
Assert.AreEqual( "myproject.config", activeConfig.ConfigurationFile );
290
Assert.AreEqual( TestPath( "/test/myproject.config" ), activeConfig.ConfigurationFilePath );
294
public void AbsoluteConfigurationFile()
296
string path1 = TestPath("/configs/myconfig.config");
297
activeConfig.ConfigurationFile = path1;
298
Assert.AreEqual( path1, activeConfig.ConfigurationFilePath );
302
public void RelativeConfigurationFile()
304
activeConfig.ConfigurationFile = "myconfig.config";
305
Assert.AreEqual( TestPath( "/test/myconfig.config" ), activeConfig.ConfigurationFilePath );
309
public void SettingActiveConfigPrivateBinPathMarksProjectDirty()
311
activeConfig.PrivateBinPath = TestPath("/junk") + Path.PathSeparator + TestPath("/bin");
312
Assert.IsTrue(project.IsDirty);
316
public void SettingActiveConfigPrivateBinPathRequiresReload()
318
activeConfig.PrivateBinPath = TestPath("/junk") + Path.PathSeparator + TestPath("/bin");
319
Assert.IsTrue(project.HasChangesRequiringReload);
323
public void SettingInactiveConfigPrivateBinPathMarksProjectDirty()
325
inactiveConfig.PrivateBinPath = TestPath("/junk") + Path.PathSeparator + TestPath("/bin");
326
Assert.IsTrue(project.IsDirty);
330
public void SettingInactiveConfigPrivateBinPathDoesNotRequireReload()
332
inactiveConfig.PrivateBinPath = TestPath("/junk") + Path.PathSeparator + TestPath("/bin");
333
Assert.IsFalse(project.HasChangesRequiringReload);
337
public void SettingActiveConfigBinPathTypeMarksProjectDirty()
339
activeConfig.BinPathType = BinPathType.Manual;
340
Assert.IsTrue(project.IsDirty);
344
public void SettingActiveConfigBinPathTypeRequiresReload()
346
activeConfig.BinPathType = BinPathType.Manual;
347
Assert.IsTrue(project.HasChangesRequiringReload);
351
public void SettingInactiveConfigBinPathTypeMarksProjectDirty()
353
inactiveConfig.BinPathType = BinPathType.Manual;
354
Assert.IsTrue(project.IsDirty);
358
public void SettingInactiveConfigBinPathTypeDoesNotRequireReload()
360
inactiveConfig.BinPathType = BinPathType.Manual;
361
Assert.IsFalse(project.HasChangesRequiringReload);
365
public void NoPrivateBinPath()
367
activeConfig.Assemblies.Add( TestPath( "/bin/assembly1.dll" ) );
368
activeConfig.Assemblies.Add( TestPath( "/bin/assembly2.dll" ) );
369
activeConfig.BinPathType = BinPathType.None;
370
Assert.IsNull( activeConfig.PrivateBinPath );
374
public void ManualPrivateBinPath()
376
activeConfig.Assemblies.Add( TestPath( "/test/bin/assembly1.dll" ) );
377
activeConfig.Assemblies.Add( TestPath( "/test/bin/assembly2.dll" ) );
378
activeConfig.BinPathType = BinPathType.Manual;
379
activeConfig.PrivateBinPath = TestPath( "/test" );
380
Assert.AreEqual( TestPath( "/test" ), activeConfig.PrivateBinPath );
383
// TODO: Move to DomainManagerTests
385
// public void AutoPrivateBinPath()
387
// config.Assemblies.Add( TestPath( "/test/bin/assembly1.dll" ) );
388
// config.Assemblies.Add( TestPath( "/test/bin/assembly2.dll" ) );
389
// config.BinPathType = BinPathType.Auto;
390
// Assert.AreEqual( "bin", config.PrivateBinPath );