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 NUnit.TestUtilities;
11
namespace NUnit.Util.Tests
13
// TODO: Some of these tests are really tests of VSProject and should be moved there.
16
public class NUnitProjectLoad
18
static readonly string xmlfile = Path.Combine(Path.GetTempPath(), "test.nunit");
19
static readonly string mockDll = NUnit.Tests.Assemblies.MockAssembly.AssemblyPath;
21
private ProjectService projectService;
22
private NUnitProject project;
27
projectService = new ProjectService();
28
project = projectService.EmptyProject();
32
public void TearDown()
34
if ( File.Exists( xmlfile ) )
35
File.Delete( xmlfile );
38
// Write a string out to our xml file and then load project from it
39
private void LoadProject( string source )
41
StreamWriter writer = new StreamWriter( xmlfile );
42
writer.Write( source );
45
project.ProjectPath = Path.GetFullPath( xmlfile );
50
public void LoadEmptyProject()
52
LoadProject( NUnitProjectXml.EmptyProject );
53
Assert.AreEqual( 0, project.Configs.Count );
57
public void LoadEmptyConfigs()
59
LoadProject( NUnitProjectXml.EmptyConfigs );
60
Assert.AreEqual( 2, project.Configs.Count );
61
Assert.IsTrue( project.Configs.Contains( "Debug") );
62
Assert.IsTrue( project.Configs.Contains( "Release") );
66
public void LoadNormalProject()
68
LoadProject( NUnitProjectXml.NormalProject );
69
Assert.AreEqual( 2, project.Configs.Count );
71
string tempPath = Path.GetTempPath();
73
ProjectConfig config1 = project.Configs["Debug"];
74
Assert.AreEqual( 2, config1.Assemblies.Count );
75
Assert.AreEqual( Path.Combine(tempPath, @"bin" + Path.DirectorySeparatorChar + "debug" + Path.DirectorySeparatorChar + "assembly1.dll" ), config1.Assemblies[0] );
76
Assert.AreEqual( Path.Combine(tempPath, @"bin" + Path.DirectorySeparatorChar + "debug" + Path.DirectorySeparatorChar + "assembly2.dll" ), config1.Assemblies[1] );
78
ProjectConfig config2 = project.Configs["Release"];
79
Assert.AreEqual( 2, config2.Assemblies.Count );
80
Assert.AreEqual( Path.Combine(tempPath, @"bin" + Path.DirectorySeparatorChar + "release" + Path.DirectorySeparatorChar + "assembly1.dll" ), config2.Assemblies[0] );
81
Assert.AreEqual( Path.Combine(tempPath, @"bin" + Path.DirectorySeparatorChar + "release" + Path.DirectorySeparatorChar + "assembly2.dll" ), config2.Assemblies[1] );
85
public void LoadProjectWithManualBinPath()
87
LoadProject( NUnitProjectXml.ManualBinPathProject );
88
Assert.AreEqual( 1, project.Configs.Count );
89
ProjectConfig config1 = project.Configs["Debug"];
90
Assert.AreEqual( "bin_path_value", config1.PrivateBinPath );
94
public void FromAssembly()
96
NUnitProject project = projectService.WrapAssembly(mockDll);
97
Assert.AreEqual( "Default", project.ActiveConfigName );
98
Assert.SamePath( mockDll, project.ActiveConfig.Assemblies[0] );
99
Assert.IsTrue( project.IsLoadable, "Not loadable" );
100
Assert.IsTrue( project.IsAssemblyWrapper, "Not wrapper" );
101
Assert.IsFalse( project.IsDirty, "Not dirty" );
105
public void SaveClearsAssemblyWrapper()
107
NUnitProject project = projectService.WrapAssembly(mockDll);
108
project.Save( xmlfile );
109
Assert.IsFalse( project.IsAssemblyWrapper,
110
"Changed project should no longer be wrapper");
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 NUnit.TestUtilities;
11
namespace NUnit.Util.Tests
13
// TODO: Some of these tests are really tests of VSProject and should be moved there.
16
public class NUnitProjectLoad
18
static readonly string xmlfile = Path.Combine(Path.GetTempPath(), "test.nunit");
19
static readonly string mockDll = NUnit.Tests.Assemblies.MockAssembly.AssemblyPath;
21
private ProjectService projectService;
22
private NUnitProject project;
27
projectService = new ProjectService();
28
project = projectService.EmptyProject();
32
public void TearDown()
34
if ( File.Exists( xmlfile ) )
35
File.Delete( xmlfile );
38
// Write a string out to our xml file and then load project from it
39
private void LoadProject( string source )
41
StreamWriter writer = new StreamWriter( xmlfile );
42
writer.Write( source );
45
project.ProjectPath = Path.GetFullPath( xmlfile );
50
public void LoadEmptyProject()
52
LoadProject( NUnitProjectXml.EmptyProject );
53
Assert.AreEqual( 0, project.Configs.Count );
57
public void LoadEmptyConfigs()
59
LoadProject( NUnitProjectXml.EmptyConfigs );
60
Assert.AreEqual( 2, project.Configs.Count );
61
Assert.IsTrue( project.Configs.Contains( "Debug") );
62
Assert.IsTrue( project.Configs.Contains( "Release") );
66
public void LoadNormalProject()
68
LoadProject( NUnitProjectXml.NormalProject );
69
Assert.AreEqual( 2, project.Configs.Count );
71
string tempPath = Path.GetTempPath();
73
ProjectConfig config1 = project.Configs["Debug"];
74
Assert.AreEqual( 2, config1.Assemblies.Count );
75
Assert.AreEqual( Path.Combine(tempPath, @"bin" + Path.DirectorySeparatorChar + "debug" + Path.DirectorySeparatorChar + "assembly1.dll" ), config1.Assemblies[0] );
76
Assert.AreEqual( Path.Combine(tempPath, @"bin" + Path.DirectorySeparatorChar + "debug" + Path.DirectorySeparatorChar + "assembly2.dll" ), config1.Assemblies[1] );
78
ProjectConfig config2 = project.Configs["Release"];
79
Assert.AreEqual( 2, config2.Assemblies.Count );
80
Assert.AreEqual( Path.Combine(tempPath, @"bin" + Path.DirectorySeparatorChar + "release" + Path.DirectorySeparatorChar + "assembly1.dll" ), config2.Assemblies[0] );
81
Assert.AreEqual( Path.Combine(tempPath, @"bin" + Path.DirectorySeparatorChar + "release" + Path.DirectorySeparatorChar + "assembly2.dll" ), config2.Assemblies[1] );
85
public void LoadProjectWithManualBinPath()
87
LoadProject( NUnitProjectXml.ManualBinPathProject );
88
Assert.AreEqual( 1, project.Configs.Count );
89
ProjectConfig config1 = project.Configs["Debug"];
90
Assert.AreEqual( "bin_path_value", config1.PrivateBinPath );
94
public void FromAssembly()
96
NUnitProject project = projectService.WrapAssembly(mockDll);
97
Assert.AreEqual( "Default", project.ActiveConfigName );
98
Assert.SamePath( mockDll, project.ActiveConfig.Assemblies[0] );
99
Assert.IsTrue( project.IsLoadable, "Not loadable" );
100
Assert.IsTrue( project.IsAssemblyWrapper, "Not wrapper" );
101
Assert.IsFalse( project.IsDirty, "Not dirty" );
105
public void SaveClearsAssemblyWrapper()
107
NUnitProject project = projectService.WrapAssembly(mockDll);
108
project.Save( xmlfile );
109
Assert.IsFalse( project.IsAssemblyWrapper,
110
"Changed project should no longer be wrapper");