PageRenderTime 36ms CodeModel.GetById 27ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/src/NUnit/interfaces/TestAssemblyInfo.cs

#
C# | 146 lines | 85 code | 13 blank | 48 comment | 1 complexity | ed174acac52e7f2a67d60cc04b590e91 MD5 | raw file
  1// ****************************************************************
  2// Copyright 2007, Charlie Poole
  3// This is free software licensed under the NUnit license. You may
  4// obtain a copy of the license at http://nunit.org
  5// ****************************************************************
  6using System;
  7using System.Collections;
  8using System.Reflection;
  9using System.Diagnostics;
 10using System.IO;
 11using System.Text;
 12
 13namespace NUnit.Core
 14{
 15	/// <summary>
 16	/// TestAssemblyInfo holds information about a loaded test assembly
 17	/// </summary>
 18	[Serializable]
 19	public class TestAssemblyInfo
 20	{
 21		private string assemblyName;
 22        private Version imageRuntimeVersion;
 23        private RuntimeFramework runnerRuntimeFramework;
 24        private int processId;
 25        private string moduleName;
 26        private string domainName;
 27        private string appBase;
 28        private string binPath;
 29        private string configFile;
 30        private IList testFrameworks;
 31
 32        /// <summary>
 33        /// Constructs a TestAssemblyInfo
 34        /// </summary>
 35        /// <param name="assemblyName">The name of the assembly</param>
 36        /// <param name="imageRuntimeVersion">The version of the runtime for which the assembly was built</param>
 37        /// <param name="runnerRuntimeFramework">The runtime framework under which the assembly is loaded</param>
 38        /// <param name="testFrameworks">A list of test framework useds by the assembly</param>
 39		public TestAssemblyInfo( string assemblyName, Version imageRuntimeVersion, RuntimeFramework runnerRuntimeFramework, IList testFrameworks )
 40		{
 41			this.assemblyName = assemblyName;
 42            this.imageRuntimeVersion = imageRuntimeVersion;
 43            this.runnerRuntimeFramework = runnerRuntimeFramework;
 44            this.testFrameworks = testFrameworks;
 45            Process p = Process.GetCurrentProcess();
 46            this.processId = p.Id;
 47			Assembly entryAssembly = Assembly.GetEntryAssembly();
 48            this.moduleName = entryAssembly != null
 49				? Path.GetFileName(Assembly.GetEntryAssembly().Location)
 50				: p.MainModule.ModuleName;
 51            this.domainName = AppDomain.CurrentDomain.FriendlyName;
 52            this.appBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
 53            this.configFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
 54            this.binPath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath;
 55		}
 56
 57        /// <summary>
 58        /// Gets the name of the assembly
 59        /// </summary>
 60		public string Name
 61		{
 62			get { return assemblyName; }
 63		}
 64
 65        /// <summary>
 66        /// Gets the runtime version for which the assembly was built
 67        /// </summary>
 68        public Version ImageRuntimeVersion
 69        {
 70            get { return imageRuntimeVersion; }
 71        }
 72
 73        /// <summary>
 74        /// Gets the runtime framework under which the assembly is loaded
 75        /// </summary>
 76        public RuntimeFramework RunnerRuntimeFramework
 77        {
 78            get { return runnerRuntimeFramework; }
 79        }
 80
 81        /// <summary>
 82        /// Gets the runtime version under which the assembly is loaded
 83        /// </summary>
 84        public Version RunnerRuntimeVersion
 85        {
 86            get { return runnerRuntimeFramework.ClrVersion; }
 87        }
 88
 89        /// <summary>
 90        /// The Id of the process in which the assembly is loaded
 91        /// </summary>
 92        public int ProcessId
 93        {
 94            get { return processId; }
 95        }
 96
 97        /// <summary>
 98        /// The friendly name of the AppDomain in which the assembly is loaded
 99        /// </summary>
100        public string DomainName
101        {
102            get { return domainName; }
103        }
104
105        /// <summary>
106        /// The Application Base of the AppDomain in which the assembly is loaded
107        /// </summary>
108        public string ApplicationBase
109        {
110            get { return appBase; }
111        }
112
113        /// <summary>
114        /// The PrivateBinPath of the AppDomain in which the assembly is loaded
115        /// </summary>
116        public string PrivateBinPath
117        {
118            get { return binPath; }
119        }
120
121        /// <summary>
122        /// The ConfigurationFile of the AppDomain in which the assembly is loaded
123        /// </summary>
124        public string ConfigurationFile
125        {
126            get { return configFile; }
127        }
128
129        /// <summary>
130        /// The name of the main module of the process in which the assembly is loaded 
131        /// </summary>
132        public string ModuleName
133        {
134            get { return moduleName; }
135			set { moduleName = value; }
136        }
137
138        /// <summary>
139        /// Gets a list of testframeworks referenced by the assembly
140        /// </summary>
141		public IList TestFrameworks
142		{
143			get { return testFrameworks; }
144		}
145    }
146}