Esempio n. 1
0
 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>());
 }
Esempio n. 2
0
 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));
 }
 public bool CanHandleTestFor(string assembly)
 {
     if (!_configuration.UseAutoTestTestRunner)
         return false;
     if (!File.Exists(assembly))
         return false;
     var plugins = new PluginLocator().Locate();
     foreach (var plugin in plugins)
     {
         var instance = plugin.New();
         if (instance == null)
             continue;
         if (instance.ContainsTestsFor(assembly))
             return true;
     }
     return false;
 }
Esempio n. 4
0
 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();
 }
Esempio n. 5
0
        private string getTestRunner(string testRunner, string assembly, string test)
        {
            if (testRunner.ToLower() != "any")
                return testRunner;

            var currentDirectory = Environment.CurrentDirectory;
            try
            {
                Environment.CurrentDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                var plugins = new PluginLocator().Locate();
                foreach (var plugin in plugins)
                {
                    var instance = plugin.New();
                    if (instance == null)
                        continue;
                    if (instance.IsTest(assembly, test))
                        return instance.Identifier;
                }
            }
            catch (Exception ex)
            {
                AutoTest.Core.DebugLog.Debug.WriteException(ex);
            }
            finally
            {
                Environment.CurrentDirectory = currentDirectory;
            }
            return testRunner;
        }
 private RunOptions generateOptions(TestRunInfo[] runInfos)
 {
     var options = new RunOptions();
     var plugins = new PluginLocator().Locate();
     foreach (var plugin in plugins)
     {
         var testRun = getTests(plugin, runInfos);
         if (testRun != null)
             options.AddTestRun(testRun);
     }
         
     if (options.TestRuns.Count() == 0)
         return null;
     return options;
 }
 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;
 }