PageRenderTime 44ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/src/NUnit/interfaces/TestAssemblyInfo.cs

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