Exemplo n.º 1
0
        public override bool Load(TestPackage package)
        {
            NTrace.Info("Loading test package " + package.Name);

            // Initialize ExtensionHost if not already done
            if (!CoreExtensions.Host.Initialized)
            {
                CoreExtensions.Host.InitializeService();
            }

            // Delayed creation of downstream runner allows us to
            // use a different runner type based on the package
            bool useThreadedRunner = package.GetSetting("UseThreadedRunner", true);

            TestRunner runner = new SimpleTestRunner(this.runnerID);

            if (useThreadedRunner)
            {
                runner = new ThreadedTestRunner(runner);
            }

            this.TestRunner = runner;

            return(base.Load(package));
        }
        public void InstallBuiltins()
        {
            NTrace.Info("Installing Builtins");

            // Define NUnit Framework
            FrameworkRegistry.Register("NUnit", "nunit.framework");

            // Install builtin SuiteBuilders - Note that the
            // NUnitTestCaseBuilder is installed whenever
            // an NUnitTestFixture is being populated and
            // removed afterward.
            suiteBuilders.Install(new Builders.NUnitTestFixtureBuilder());
            suiteBuilders.Install(new Builders.SetUpFixtureBuilder());
        }
        private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            string fullName = args.Name;
            int    index    = fullName.IndexOf(',');

            if (index == -1)                                                            // Only resolve using full name.
            {
                NTrace.Debug(string.Format("Not a strong name: {0}", fullName),
                             "'AssemblyResolver'");
                return(null);
            }

            if (_cache.Contains(fullName))
            {
                NTrace.Info(string.Format("Resolved from Cache: {0}", fullName),
                            "'AssemblyResolver'");
                return(_cache.Resolve(fullName));
            }

            foreach (string dir in _dirs)
            {
                foreach (string file in Directory.GetFiles(dir, "*.dll"))
                {
                    string fullFile = Path.Combine(dir, file);
                    try
                    {
                        if (AssemblyName.GetAssemblyName(fullFile).FullName == fullName)
                        {
                            NTrace.Info(string.Format("Added to Cache: {0}", fullFile),
                                        "'AssemblyResolver'");
                            AddFile(fullFile);
                            return(_cache.Resolve(fullName));
                        }
                    }
                    catch
                    {
                        // Keep going if there's a bad assembly
                        NTrace.Debug(string.Format("Bad assembly: {0}", fullFile), "AssemblyResolver");
                    }
                }
            }

            NTrace.Debug(string.Format("Not in Cache: {0}", fullName),
                         "'AssemblyResolver'");
            return(null);
        }
        public void InstallAddins()
        {
            NTrace.Info("Installing Addins");

            if (AddinRegistry != null)
            {
                foreach (Addin addin in AddinRegistry.Addins)
                {
                    if ((this.ExtensionTypes & addin.ExtensionType) != 0)
                    {
                        try
                        {
                            Type type = Type.GetType(addin.TypeName);
                            if (type == null)
                            {
                                AddinRegistry.SetStatus(addin.Name, AddinStatus.Error, "Could not locate type");
                                NTrace.Error("Failed to load  " + addin.Name + " - Could not locate type");
                            }
                            else if (!InstallAddin(type))
                            {
                                AddinRegistry.SetStatus(addin.Name, AddinStatus.Error, "Install returned false");
                                NTrace.Error("Failed to load " + addin.Name + " - Install returned false");
                            }
                            else
                            {
                                AddinRegistry.SetStatus(addin.Name, AddinStatus.Loaded, null);
                            }
                        }
                        catch (Exception ex)
                        {
                            AddinRegistry.SetStatus(addin.Name, AddinStatus.Error, ex.Message);
                            NTrace.Error("Exception loading " + addin.Name + " - " + ex.Message);
                        }
                    }
                }
            }
        }