public IEnumerable<Plugin> Locate()
 {
     var plugins = new List<Plugin>();
     var hitPaths = new string[]
                         {
                             _path,
                             Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)
                         };
     hitPaths.ToList().ForEach(x => Logger.Write("Hint path (locate): " + x));
     using (var resolver = new AssemblyResolver(hitPaths))
     {
         var currentDirectory = Environment.CurrentDirectory;
         try
         {
             Environment.CurrentDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
             var files = Directory.GetFiles(_path, "*.*", SearchOption.AllDirectories);
             foreach (var file in files)
                 plugins.AddRange(getPlugins(Path.GetFullPath(file)));
         }
         finally
         {
             Environment.CurrentDirectory = currentDirectory;
         }
     }
     return plugins;
 }
示例#2
0
 public IEnumerable<Plugin> Locate()
 {
     var plugins = new List<Plugin>();
     var hitPaths = new string[]
                         {
                             _path,
                             Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath)
                         };
     using (var resolver = new AssemblyResolver(hitPaths))
     {
         var currentDirectory = Environment.CurrentDirectory;
         try
         {
             Environment.CurrentDirectory = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
             var files = Directory.GetFiles(_path, "*.*", SearchOption.AllDirectories);
             foreach (var file in files)
                 plugins.AddRange(getPlugins(file));
         }
         finally
         {
             Environment.CurrentDirectory = currentDirectory;
         }
     }
     return plugins;
 }
        public IAutoTestNetTestRunner New()
        {
            IAutoTestNetTestRunner runner;
            var hitPaths = new string[]
                                {
                                    Path.GetDirectoryName(Assembly),
                                    Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)
                                };

            hitPaths.ToList().ForEach(x => Logger.Write("Hint path (new): " + x));
            using (var resolver = new AssemblyResolver(hitPaths))
            {
                try
                {
                    var asm = System.Reflection.Assembly.LoadFrom(Assembly);
                    runner = (IAutoTestNetTestRunner)asm.CreateInstance(Type);
                }
                catch (Exception ex)
                {
                    Logger.Write(ex);
                    return null;
                }
            }
            runner.SetLogger(Logger.Instance);
            runner.SetReflectionProvider((assembly) => { return Reflect.On(assembly); });
            runner.SetLiveFeedbackChannel(new NullTestFeedbackProvider());
            return runner;
        }
示例#4
0
 public IEnumerable<TestResult> Run(bool startLogger, Plugin plugin, string id, RunSettings settings)
 {
     if (startLogger)
         Logger.SetLogger(new ConsoleLogger());
     IEnumerable<TestResult> resultSet = null;
     var directories = new List<string>();
     directories.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
     directories.Add(Path.GetDirectoryName(settings.Assembly.Assembly));
     directories.Add(Path.GetDirectoryName(plugin.Assembly));
     using (var resolver = new AssemblyResolver(directories.ToArray()))
     {
         Logger.Write("About to create plugin {0} in {1} for {2}", plugin.Type, plugin.Assembly, id);
         var runner = getRunner(plugin);
         var currentDirectory = Environment.CurrentDirectory;
         try
         {
             if (runner == null)
                 return _results;
             using (var server = new PipeServer(settings.PipeName))
             {
                 Logger.Write("Matching plugin identifier ({0}) to test identifier ({1})", runner.Identifier, id);
                 if (!runner.Identifier.ToLower().Equals(id.ToLower()) && !id.ToLower().Equals("any"))
                     return _results;
                 Logger.Write("Checking whether assembly contains tests for {0}", id);
                 if (!settings.Assembly.IsVerified && !runner.ContainsTestsFor(settings.Assembly.Assembly))
                     return _results;
                 Logger.Write("Initializing channel");
                 runner.SetLiveFeedbackChannel(new TestFeedbackProvider(server));
                 var newCurrent = Path.GetDirectoryName(settings.Assembly.Assembly);
                 Logger.Write("Setting current directory to " + newCurrent);
                 Environment.CurrentDirectory = newCurrent;
                 Logger.Write("Starting test run");
                 resultSet = runner.Run(settings);
             }
         }
         catch
         {
             throw;
         }
         finally
         {
             Environment.CurrentDirectory = currentDirectory;
         }
     }
     return resultSet;
 }
示例#5
0
 public IAutoTestNetTestRunner New()
 {
     var hitPaths = new string[]
                         {
                             Path.GetDirectoryName(Assembly),
                             Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath)
                         };
     using (var resolver = new AssemblyResolver(hitPaths))
     {
         try
         {
             var asm = System.Reflection.Assembly.LoadFrom(Assembly);
             var runner = (IAutoTestNetTestRunner)asm.CreateInstance(Type);
             runner.SetLogger(Logger.Instance);
             return runner;
         }
         catch
         {
             return null;
         }
     }
 }
        public void Load(string assembly)
        {
            if (!File.Exists(assembly))
                return;

            var hitPaths = new[]
                                {
                                    Path.GetDirectoryName(assembly),
                                    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
                                };
            //TODO GFY WTF why do we not use the resolver?
            // The only reason we pull a resolver out is so that we
            // can have a using statement
            // The assembly resovler binds up the AppDomain resolve
            // event. We need to manually handle dependency resolves
            // as the dll are in various different directories.
            // Because of the using it will unbind the event.
            using (var resolver = new AssemblyResolver(hitPaths))
            {
                try
                {
                    _assembly = Assembly.LoadFrom(assembly);
                }
                catch (Exception ex)
                {
                    Logging.Logger.Write(ex);
                }
            }
        }
        public IEnumerable<Plugin> Locate()
        {
            var plugins = new List<Plugin>();
            var hitPaths = new string[]
            {
                _path,
                Path.Combine(GetAutoTestDirectory(), "TestRunners"),
                Path.Combine(GetExecutingAssemblyDirectory(), "TestRunners"),
            };
            hitPaths.ToList().ForEach(x => Logger.Write("Hint path (locate): " + x));
            using (var resolver = new AssemblyResolver(hitPaths))
            {
                var currentDirectory = Environment.CurrentDirectory;
                try
                {
                    Environment.CurrentDirectory = GetAutoTestDirectory();
                    var files = Directory.GetFiles(_path, "*.*", SearchOption.AllDirectories);
                    foreach (var file in files)
                    {
                        try
                        {
                            plugins.AddRange(getPlugins(Path.GetFullPath(file)));
                        }
                        catch (DirectoryNotFoundException)
                        {

                        }
                    }
                }
                finally
                {
                    Environment.CurrentDirectory = currentDirectory;
                }
            }
            return plugins;
        }
        public void Load(string assembly)
        {
            if (!File.Exists(assembly))
                return;

            var hitPaths = new string[]
                                {
                                    Path.GetDirectoryName(assembly),
                                    Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath)
                                };
            using (var resolver = new AssemblyResolver(hitPaths))
            {
                try
                {
                    _assembly = Assembly.LoadFrom(assembly);
                }
                catch (Exception ex)
                {
                    Logging.Logger.Write(ex);
                }
            }
        }