Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab/3.3/Tests/PluginLoader.cs @ 5404

Last change on this file since 5404 was 5306, checked in by mkommend, 14 years ago

Corrected HL3.3 tests project to test all assemblies and not only assemblies that contain a Plugin class (ticket #1351).

File size: 1.0 KB
Line 
1
2using System;
3using System.Collections.Generic;
4using System.IO;
5using System.Linq;
6using System.Reflection;
7using HeuristicLab.PluginInfrastructure;
8
9namespace HeuristicLab_33.Tests {
10  internal static class PluginLoader {
11    public const string AssemblyExtension = ".dll";
12    public const string TestAccessorAssemblyExtension = "_Accessor.dll";
13    public const string TestAssemblyExtension = ".Tests.dll";
14    public static List<Assembly> Assemblies;
15
16    static PluginLoader() {
17      foreach (string path in Directory.EnumerateFiles(Environment.CurrentDirectory)
18        .Where(s => s.EndsWith(AssemblyExtension) && !s.EndsWith(TestAccessorAssemblyExtension) && !s.EndsWith(TestAssemblyExtension)))
19        Assembly.LoadFrom(path);
20
21      Assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
22    }
23
24    public static bool IsPluginAssembly(Assembly assembly) {
25      return assembly.GetExportedTypes()
26        .Where(t => typeof(IPlugin).IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface).Any();
27    }
28  }
29}
Note: See TracBrowser for help on using the repository browser.