GetAssemblyPath() public static method

Gets the path from which an assembly was loaded. For builds where this is not possible, returns the name of the assembly.
public static GetAssemblyPath ( Assembly assembly ) : string
assembly System.Reflection.Assembly The assembly.
return string
Example #1
0
        public void GetPathForAssembly()
        {
            string path = AssemblyHelper.GetAssemblyPath(this.GetType().GetTypeInfo().Assembly);

            Assert.That(Path.GetFileName(path), Is.EqualTo(THIS_ASSEMBLY_PATH).IgnoreCase);

            Assert.That(File.Exists(path));
        }
        /// <summary>
        /// Build a suite of tests from a provided assembly
        /// </summary>
        /// <param name="assembly">The assembly from which tests are to be built</param>
        /// <param name="options">A dictionary of options to use in building the suite</param>
        /// <returns>
        /// A TestSuite containing the tests found in the assembly
        /// </returns>
        public ITest Build(Assembly assembly, IDictionary options)
        {
            this.assembly = assembly;

            IList fixtureNames = options["LOAD"] as IList;

            IList fixtures = GetFixtures(assembly, fixtureNames);

#if NETCF || SILVERLIGHT
            AssemblyName assemblyName = AssemblyHelper.GetAssemblyName(assembly);
            return(BuildTestAssembly(assemblyName.Name, fixtures));
#else
            string assemblyPath = AssemblyHelper.GetAssemblyPath(assembly);
            return(BuildTestAssembly(assemblyPath, fixtures));
#endif
        }
        /// <summary>
        /// Build a suite of tests from a provided assembly
        /// </summary>
        /// <param name="assembly">The assembly from which tests are to be built</param>
        /// <param name="options">A dictionary of options to use in building the suite</param>
        /// <returns>
        /// A TestSuite containing the tests found in the assembly
        /// </returns>
        public TestSuite Build(Assembly assembly, IDictionary options)
        {
            this.assembly = assembly;

            IList fixtureNames = options["LOAD"] as IList;

            IList fixtures = GetFixtures(assembly, fixtureNames);

            if (fixtures.Count > 0)
            {
#if NETCF || SILVERLIGHT || PORTABLE
                AssemblyName assemblyName = AssemblyHelper.GetAssemblyName(assembly);
                return(BuildTestAssembly(assemblyName.Name, fixtures));
#else
                string assemblyPath = AssemblyHelper.GetAssemblyPath(assembly);
                return(BuildTestAssembly(assemblyPath, fixtures));
#endif
            }

            return(null);
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssemblyReader"/> class.
 /// </summary>
 /// <param name="assembly">The assembly.</param>
 public AssemblyReader(Assembly assembly)
 {
     this.assemblyPath = AssemblyHelper.GetAssemblyPath(assembly);
     CalcHeaderOffsets();
 }