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

« back to all changes in this revision

Viewing changes to src/NUnitCore/tests/AssemblyVersionFixture.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;
8
 
using System.IO;
9
 
using System.Reflection;
10
 
using System.Threading;
11
 
using System.Reflection.Emit;
12
 
 
13
 
using NUnit.Framework;
14
 
 
15
 
namespace NUnit.Core.Tests
16
 
{
17
 
        [TestFixture]
18
 
        public class AssemblyVersionFixture
19
 
        {
20
 
                [Test]
21
 
        // TODO: Figure out what we're testing here! Was there a bug?
22
 
                public void Version()
23
 
                {
24
 
                        Version version = new Version("1.0.0.2002");
25
 
                        string nameString = "TestAssembly";
26
 
 
27
 
                        AssemblyName assemblyName = new AssemblyName(); 
28
 
                        assemblyName.Name = nameString;
29
 
                        assemblyName.Version = version;
30
 
                        MakeDynamicAssembly(assemblyName);
31
 
 
32
 
                        Assembly assembly = FindAssemblyByName(nameString);
33
 
 
34
 
                        System.Version foundVersion = assembly.GetName().Version;
35
 
                        Assert.AreEqual(version, foundVersion);
36
 
                }
37
 
 
38
 
                private Assembly FindAssemblyByName(string name)
39
 
                {
40
 
                        // Get all the assemblies currently loaded in the application domain.
41
 
                        Assembly[] myAssemblies = Thread.GetDomain().GetAssemblies();
42
 
 
43
 
                        Assembly assembly = null;
44
 
                        for(int i = 0; i < myAssemblies.Length && assembly == null; i++)
45
 
                        {
46
 
                                if(String.Compare(myAssemblies[i].GetName().Name, name) == 0)
47
 
                                        assembly = myAssemblies[i];
48
 
                        }
49
 
                        return assembly;
50
 
                }
51
 
 
52
 
                public static void MakeDynamicAssembly(AssemblyName myAssemblyName)
53
 
                {
54
 
                        Thread.GetDomain().DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.RunAndSave);                     
55
 
                }
56
 
        }
57
 
}
 
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;
 
8
using System.IO;
 
9
using System.Reflection;
 
10
using System.Threading;
 
11
using System.Reflection.Emit;
 
12
 
 
13
using NUnit.Framework;
 
14
 
 
15
namespace NUnit.Core.Tests
 
16
{
 
17
        [TestFixture]
 
18
        public class AssemblyVersionFixture
 
19
        {
 
20
                [Test]
 
21
        // TODO: Figure out what we're testing here! Was there a bug?
 
22
                public void Version()
 
23
                {
 
24
                        Version version = new Version("1.0.0.2002");
 
25
                        string nameString = "TestAssembly";
 
26
 
 
27
                        AssemblyName assemblyName = new AssemblyName(); 
 
28
                        assemblyName.Name = nameString;
 
29
                        assemblyName.Version = version;
 
30
                        MakeDynamicAssembly(assemblyName);
 
31
 
 
32
                        Assembly assembly = FindAssemblyByName(nameString);
 
33
 
 
34
                        System.Version foundVersion = assembly.GetName().Version;
 
35
                        Assert.AreEqual(version, foundVersion);
 
36
                }
 
37
 
 
38
                private Assembly FindAssemblyByName(string name)
 
39
                {
 
40
                        // Get all the assemblies currently loaded in the application domain.
 
41
                        Assembly[] myAssemblies = Thread.GetDomain().GetAssemblies();
 
42
 
 
43
                        Assembly assembly = null;
 
44
                        for(int i = 0; i < myAssemblies.Length && assembly == null; i++)
 
45
                        {
 
46
                                if(String.Compare(myAssemblies[i].GetName().Name, name) == 0)
 
47
                                        assembly = myAssemblies[i];
 
48
                        }
 
49
                        return assembly;
 
50
                }
 
51
 
 
52
                public static void MakeDynamicAssembly(AssemblyName myAssemblyName)
 
53
                {
 
54
                        Thread.GetDomain().DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.RunAndSave);                     
 
55
                }
 
56
        }
 
57
}