~ubuntu-branches/debian/sid/nunit/sid

« back to all changes in this revision

Viewing changes to src/ClientUtilities/tests/NUnitProjectLoad.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2014-09-16 13:43:36 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140916134336-kjxz48tty6lx2ja5
Tags: 2.6.3+dfsg-1
* [c7bd1b5] Imported Upstream version 2.6.3+dfsg
* [bcb4bf8] Move nunit-console-runner to GAC-installed libnunit2.6, 
  don't treat it as a private lib. This lib is signed, and treated 
  as a GAC lib by consumers such as MonoDevelop.
* [7f08e99] Bump version to 2.6.3 as required
* [84535eb] Refreshed patches
* [8479f61] Split package up into per-assembly packages. This makes 
  ABI tracking easier in the future, as we can meaningfully have GAC 
  policy for cases where ABI isn't truly bumped, and no policy for 
  cases where it is. For example, if nunit.framework bumps ABI but 
  nunit.core does not, previously we would need to rebuild everything 
  using NUnit, but under the new split packaging, that rebuild would 
  not be needed for apps only using nunit.core.
* [17a7dc7] Add missing nunit.mocks.dll to nunit.pc

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
// ****************************************************************
6
 
 
7
 
using System.IO;
8
 
using NUnit.Framework;
9
 
using NUnit.TestUtilities;
10
 
 
11
 
namespace NUnit.Util.Tests
12
 
{
13
 
        // TODO: Some of these tests are really tests of VSProject and should be moved there.
14
 
 
15
 
        [TestFixture]
16
 
        public class NUnitProjectLoad
17
 
        {
18
 
                static readonly string xmlfile = Path.Combine(Path.GetTempPath(), "test.nunit");
19
 
        static readonly string mockDll = NUnit.Tests.Assemblies.MockAssembly.AssemblyPath;
20
 
 
21
 
                private ProjectService projectService;
22
 
                private NUnitProject project;
23
 
 
24
 
                [SetUp]
25
 
                public void SetUp()
26
 
                {
27
 
                        projectService = new ProjectService();
28
 
                        project = projectService.EmptyProject();
29
 
                }
30
 
 
31
 
                [TearDown]
32
 
                public void TearDown()
33
 
                {
34
 
                        if ( File.Exists( xmlfile ) )
35
 
                                File.Delete( xmlfile );
36
 
                }
37
 
 
38
 
                // Write a string out to our xml file and then load project from it
39
 
                private void LoadProject( string source )
40
 
                {
41
 
                        StreamWriter writer = new StreamWriter( xmlfile );
42
 
                        writer.Write( source );
43
 
                        writer.Close();
44
 
 
45
 
                        project.ProjectPath = Path.GetFullPath( xmlfile );
46
 
                        project.Load();
47
 
                }
48
 
 
49
 
                [Test]
50
 
                public void LoadEmptyProject()
51
 
                {
52
 
                        LoadProject( NUnitProjectXml.EmptyProject );
53
 
                        Assert.AreEqual( 0, project.Configs.Count );
54
 
                }
55
 
 
56
 
                [Test]
57
 
                public void LoadEmptyConfigs()
58
 
                {
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") );
63
 
                }
64
 
 
65
 
                [Test]
66
 
                public void LoadNormalProject()
67
 
                {
68
 
                        LoadProject( NUnitProjectXml.NormalProject );
69
 
                        Assert.AreEqual( 2, project.Configs.Count );
70
 
 
71
 
            string tempPath = Path.GetTempPath();
72
 
 
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] );
77
 
 
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] );
82
 
                }
83
 
 
84
 
                [Test]
85
 
                public void LoadProjectWithManualBinPath()
86
 
                {
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 );
91
 
                }
92
 
 
93
 
                [Test]
94
 
                public void FromAssembly()
95
 
                {
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" );
102
 
                }
103
 
 
104
 
                [Test]
105
 
                public void SaveClearsAssemblyWrapper()
106
 
                {
107
 
                        NUnitProject project = projectService.WrapAssembly(mockDll);
108
 
                        project.Save( xmlfile );
109
 
                        Assert.IsFalse( project.IsAssemblyWrapper,
110
 
                                "Changed project should no longer be wrapper");
111
 
                }
112
 
        }
113
 
}
 
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
// ****************************************************************
 
6
 
 
7
using System.IO;
 
8
using NUnit.Framework;
 
9
using NUnit.TestUtilities;
 
10
 
 
11
namespace NUnit.Util.Tests
 
12
{
 
13
        // TODO: Some of these tests are really tests of VSProject and should be moved there.
 
14
 
 
15
        [TestFixture]
 
16
        public class NUnitProjectLoad
 
17
        {
 
18
                static readonly string xmlfile = Path.Combine(Path.GetTempPath(), "test.nunit");
 
19
        static readonly string mockDll = NUnit.Tests.Assemblies.MockAssembly.AssemblyPath;
 
20
 
 
21
                private ProjectService projectService;
 
22
                private NUnitProject project;
 
23
 
 
24
                [SetUp]
 
25
                public void SetUp()
 
26
                {
 
27
                        projectService = new ProjectService();
 
28
                        project = projectService.EmptyProject();
 
29
                }
 
30
 
 
31
                [TearDown]
 
32
                public void TearDown()
 
33
                {
 
34
                        if ( File.Exists( xmlfile ) )
 
35
                                File.Delete( xmlfile );
 
36
                }
 
37
 
 
38
                // Write a string out to our xml file and then load project from it
 
39
                private void LoadProject( string source )
 
40
                {
 
41
                        StreamWriter writer = new StreamWriter( xmlfile );
 
42
                        writer.Write( source );
 
43
                        writer.Close();
 
44
 
 
45
                        project.ProjectPath = Path.GetFullPath( xmlfile );
 
46
                        project.Load();
 
47
                }
 
48
 
 
49
                [Test]
 
50
                public void LoadEmptyProject()
 
51
                {
 
52
                        LoadProject( NUnitProjectXml.EmptyProject );
 
53
                        Assert.AreEqual( 0, project.Configs.Count );
 
54
                }
 
55
 
 
56
                [Test]
 
57
                public void LoadEmptyConfigs()
 
58
                {
 
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") );
 
63
                }
 
64
 
 
65
                [Test]
 
66
                public void LoadNormalProject()
 
67
                {
 
68
                        LoadProject( NUnitProjectXml.NormalProject );
 
69
                        Assert.AreEqual( 2, project.Configs.Count );
 
70
 
 
71
            string tempPath = Path.GetTempPath();
 
72
 
 
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] );
 
77
 
 
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] );
 
82
                }
 
83
 
 
84
                [Test]
 
85
                public void LoadProjectWithManualBinPath()
 
86
                {
 
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 );
 
91
                }
 
92
 
 
93
                [Test]
 
94
                public void FromAssembly()
 
95
                {
 
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" );
 
102
                }
 
103
 
 
104
                [Test]
 
105
                public void SaveClearsAssemblyWrapper()
 
106
                {
 
107
                        NUnitProject project = projectService.WrapAssembly(mockDll);
 
108
                        project.Save( xmlfile );
 
109
                        Assert.IsFalse( project.IsAssemblyWrapper,
 
110
                                "Changed project should no longer be wrapper");
 
111
                }
 
112
        }
 
113
}