public void Should_create_instance() { var path = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); var locator = new PluginLocator(path); var plugins = locator.Locate(); var plugin = plugins.Where(x => x.Assembly.Equals(Path.Combine(path, "AutoTest.TestRunners.Tests.dll")) && x.Type.Equals("AutoTest.TestRunners.Tests.Plugins.Plugin1")).First(); Assert.That(plugin.New(), Is.InstanceOf<IAutoTestNetTestRunner>()); }
public void Should_locate_plugins() { var path = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); var locator = new PluginLocator(path); var plugins = locator.Locate(); Assert.IsTrue(plugins.Count() > 0); Assert.That(plugins.Where(x => x.Assembly.Equals(Path.Combine(path, "AutoTest.TestRunners.Tests.dll")) && x.Type.Equals("AutoTest.TestRunners.Tests.Plugins.Plugin1")).Count(), Is.EqualTo(1)); Assert.That(plugins.Where(x => x.Assembly.Equals(Path.Combine(path, "AutoTest.TestRunners.Tests.dll")) && x.Type.Equals("AutoTest.TestRunners.Tests.Plugins.Plugin2")).Count(), Is.EqualTo(1)); }
private static IEnumerable<Plugin> allPlugins() { var currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var dir = Path.Combine(currentDir, "TestRunners"); if (!Directory.Exists(dir)) return new Plugin[] { }; var locator = new PluginLocator(dir); return locator.Locate(); }
private IEnumerable<IAutoTestNetTestRunner> getIdentifiers() { if (_identifiers == null) { var locator = new PluginLocator(Path.GetFullPath("TestRunners")); var plugins = locator.Locate(); _identifiers = plugins .Select(x => { var instance = x.New(); if (instance == null) Logger.WriteDebug(string.Format("Could not create plugin for {0} using {1}", x.Type, x.Assembly)); return instance; }) .Where(x => x != null); } return _identifiers; }