Esempio n. 1
0
            public AssemblyDefinition Resolve(AssemblyNameReference name)
            {
                AssemblyDefinition assemblyDefn;

                if (!cache.TryGetValue(name.FullName, out assemblyDefn))
                {
                    string assemblyFile = FindAssemblyByPartialName(name.Name);
                    if (assemblyFile == null)
                    {
                        Assembly assembly = Assembly.ReflectionOnlyLoad(name.FullName);
                        if (assembly != null)
                        {
                            assemblyFile = AssemblyUtils.GetAssemblyLocalPath(assembly);
                        }
                        else
                        {
                            throw new FileNotFoundException(String.Format("Could not find assembly '{0}'.", name.FullName));
                        }
                    }

                    assemblyDefn         = LoadAssembly(assemblyFile);
                    cache[name.FullName] = assemblyDefn; // ensure this exact variation of the full name is cached too
                }

                return(assemblyDefn);
            }
Esempio n. 2
0
        private IEnumerable <string> GetPlugins()
        {
            var acadRunnerDir = Path.GetDirectoryName(
                AssemblyUtils.GetAssemblyLocalPath(typeof(AcadPluginLocator).Assembly));

            const string searchPattern = "Gallio.AutoCAD.Plugin*.dll";

            foreach (var path in GetFilesInDirectory(acadRunnerDir, searchPattern, SearchOption.TopDirectoryOnly))
            {
                yield return(path);
            }

            // Check if Gallio is running directly out of its source tree.
            string devPath = acadRunnerDir;

            while (devPath != null && Path.GetFileName(devPath) != @"src")
            {
                devPath = Path.GetDirectoryName(devPath);
            }

            if (devPath == null)
            {
                yield break;
            }

            var projectOutputDir = Path.Combine(devPath, @"Extensions\AutoCAD\Gallio.AutoCAD.Plugin\bin");

            if (fileSystem.DirectoryExists(projectOutputDir))
            {
                foreach (var path in GetFilesInDirectory(projectOutputDir, searchPattern, SearchOption.AllDirectories))
                {
                    yield return(path);
                }
            }
        }
        private static ProcessTask RunMSTest(string options)
        {
            string value = (string)RegistryUtils.GetValueWithBitness(
                ProcessorArchitecture.X86, RegistryHive.LocalMachine,
                @"Software\Microsoft\VisualStudio\9.0",
                "InstallDir", null);

            if (value == null)
            {
                Assert.Inconclusive("Visual Studio 2008 does not appear to be installed.");
            }

            string executablePath = Path.Combine(value, "MSTest.exe");

            if (!File.Exists(executablePath))
            {
                Assert.Inconclusive("Visual Studio 2008 appears to be installed but MSTest.exe was not found.");
            }

            string testAssemblyPath = AssemblyUtils.GetAssemblyLocalPath(typeof(SimpleTest).Assembly);
            string workingDirectory = Path.GetDirectoryName(AssemblyUtils.GetAssemblyLocalPath(typeof(GallioTipIntegrationTest).Assembly));

            ProcessTask task = Tasks.StartProcessTask(executablePath,
                                                      "\"/testcontainer:" + testAssemblyPath + "\" " + options,
                                                      workingDirectory);

            Assert.IsTrue(task.Run(TimeSpan.FromSeconds(60)), "A timeout occurred.");
            return(task);
        }
        public void GetXmlDocumentation_GetsDocumentationForDocumentedMember()
        {
            Type type = typeof(DocumentedClass);

            Assert.AreEqual("<summary>\nA documented class.\n</summary>\n<remarks>\nThe XML documentation of this test is significant.\n  Including the leading whitespace on this line.\n    And the extra 8 trailing spaces on this line!\n</remarks>",
                            resolver.GetXmlDocumentation(AssemblyUtils.GetAssemblyLocalPath(type.Assembly), "T:" + type.FullName));
        }
        public void FallsBackOnNativelyLoadableAssemblies()
        {
            ReflectionOnlyAssemblyLoader loader = new ReflectionOnlyAssemblyLoader();
            Assembly      nativeAssembly        = typeof(ReflectionOnlyAssemblyLoader).Assembly;
            IAssemblyInfo assembly = loader.ReflectionPolicy.LoadAssembly(nativeAssembly.GetName());

            Assert.AreEqual(AssemblyUtils.GetAssemblyLocalPath(nativeAssembly), assembly.Path);
        }
        public void FixtureSetUp()
        {
            string binPath = Path.GetDirectoryName(AssemblyUtils.GetAssemblyLocalPath(GetType().Assembly));

            workingDirectory = Path.Combine(binPath, @"..\TestBuildFiles");
            executablePath   = Path.Combine(binPath, @"..\..\libs\NAnt.exe");

            Assert.IsTrue(File.Exists(executablePath), "Cannot find the NAnt executable!");
        }
Esempio n. 7
0
        /// <summary>
        /// Sets the configuration file path to the *.config file associated with an assembly.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="assembly"/> is null.</exception>
        public void SetConfigurationFilePathFromAssembly(Assembly assembly)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

            configurationFilePath = AssemblyUtils.GetAssemblyLocalPath(assembly) + @".config";
        }
        private ProcessTask StartAmbienceServer(string arguments)
        {
            string workingDirectory = Path.GetDirectoryName((AssemblyUtils.GetAssemblyLocalPath(GetType().Assembly)));
            string executablePath   = Path.Combine(workingDirectory, "Gallio.Ambience.Server.exe");

            ProcessTask task = Tasks.StartProcessTask(executablePath, arguments, workingDirectory);

            Thread.Sleep(10000);
            return(task);
        }
        public void FixtureSetUp()
        {
            string frameworkPath = RuntimeEnvironment.GetRuntimeDirectory();

            executablePath = frameworkPath + @"MSBuild.exe";

            Assert.IsTrue(File.Exists(executablePath), "Cannot find the MSBuild executable!");

            workingDirectory = Path.Combine(Path.GetDirectoryName(AssemblyUtils.GetAssemblyLocalPath(GetType().Assembly)), @"..\TestBuildFiles");
        }
Esempio n. 10
0
        public void CreateInstanceFromCreatesAValidObjectHandle()
        {
            using (IHost host = Factory.CreateHost(new HostSetup(), new MarkupStreamLogger(TestLog.Default)))
            {
                Type serviceType = typeof(RemoteHostFactoryTest.TestService);
                RemoteHostFactoryTest.TestService serviceProxy = (RemoteHostFactoryTest.TestService)host.GetHostService().CreateInstanceFrom(
                    AssemblyUtils.GetAssemblyLocalPath(serviceType.Assembly), serviceType.FullName).Unwrap();

                Assert.AreEqual(42, serviceProxy.Add(23, 19));
            }
        }
        public void LoadsAssembliesFromHintPathPreferentially()
        {
            ReflectionOnlyAssemblyLoader loader = new ReflectionOnlyAssemblyLoader();
            string binDir = Path.GetDirectoryName(AssemblyUtils.GetAssemblyLocalPath(typeof(ReflectionOnlyAssemblyLoader).Assembly));

            loader.AddHintDirectory("non-existent-folder-is-ignored-without-sideeffects");
            loader.AddHintDirectory(binDir);

            IAssemblyInfo assembly = loader.ReflectionPolicy.LoadAssembly(new AssemblyName("Gallio")); // would ordinarily be loaded from somewhere else

            Assert.StartsWith(assembly.Path, binDir);
        }
        public void FormatWritesTheTransformedReport()
        {
            string resourcePath = Path.Combine(Path.GetDirectoryName(AssemblyUtils.GetAssemblyLocalPath(GetType().Assembly)), @"..\Reports");

            IReportWriter    reportWriter    = Mocks.StrictMock <IReportWriter>();
            IReportContainer reportContainer = Mocks.StrictMock <IReportContainer>();
            IProgressMonitor progressMonitor = NullProgressMonitor.CreateInstance();

            string reportPath = SpecialPathPolicy.For <XsltReportFormatter>().CreateTempFileWithUniqueName().FullName;

            using (Stream tempFileStream = File.OpenWrite(reportPath))
            {
                using (Mocks.Record())
                {
                    SetupResult.For(reportWriter.ReportContainer).Return(reportContainer);

                    reportWriter.SerializeReport(null, AttachmentContentDisposition.Link);
                    LastCall.Constraints(Is.NotNull(), Is.Equal(AttachmentContentDisposition.Link))
                    .Do((SerializeReportDelegate) delegate(XmlWriter writer, AttachmentContentDisposition contentDisposition)
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.InnerXml    = "<report>The report.</report>";
                        doc.Save(writer);
                    });

                    SetupResult.For(reportContainer.ReportName).Return("Foo");
                    Expect.Call(reportContainer.OpenWrite("Foo.ext", MimeTypes.PlainText, new UTF8Encoding(false)))
                    .Return(tempFileStream);
                    reportWriter.AddReportDocumentPath("Foo.ext");

                    Expect.Call(reportContainer.OpenWrite(@"Foo\MbUnitLogo.png", MimeTypes.Png, null)).Return(new MemoryStream());

                    reportWriter.SaveReportAttachments(null);
                    LastCall.Constraints(Is.NotNull());
                }

                using (Mocks.Playback())
                {
                    XsltReportFormatter formatter = new XsltReportFormatter("ext", MimeTypes.PlainText, new DirectoryInfo(resourcePath), "Diagnostic.xslt", new string[] { "MbUnitLogo.png" });
                    var reportFormatterOptions    = new ReportFormatterOptions();
                    reportFormatterOptions.AddProperty(XsltReportFormatter.AttachmentContentDispositionOption, AttachmentContentDisposition.Link.ToString());

                    formatter.Format(reportWriter, reportFormatterOptions, progressMonitor);

                    string reportContents = File.ReadAllText(reportPath);
                    TestLog.EmbedXml("Diagnostic report contents", reportContents);
                    Assert.Contains(reportContents, "<resourceRoot>Foo</resourceRoot>");
                    Assert.Contains(reportContents, "The report.");

                    File.Delete(reportPath);
                }
            }
        }
Esempio n. 13
0
 public string ResolveAssemblyLocalPath(string assemblyName, bool reflectionOnly)
 {
     try
     {
         Assembly assembly = reflectionOnly ? Assembly.ReflectionOnlyLoad(assemblyName) : Assembly.Load(assemblyName);
         return(AssemblyUtils.GetAssemblyLocalPath(assembly));
     }
     catch
     {
         return(null);
     }
 }
        private static void RunInstallScript(string options)
        {
            string installScriptDir  = Path.GetFullPath(Path.Combine(AssemblyUtils.GetAssemblyLocalPath(typeof(GallioTipIntegrationTest).Assembly), @"..\..\..\..\..\.."));
            string installScriptPath = Path.Combine(installScriptDir, "Install.bat");

            // We start our process manually because if we use the tasks, it will redirect output
            // which causes the "sed" program used by the script to malfunction.  Crazy Windows shell...
            DiagnosticLog.WriteLine(installScriptPath);
            Process process = Process.Start(installScriptPath, options);

            process.WaitForExit();
            Assert.AreEqual(0, process.ExitCode, "The install script failed.");
        }
        public void TaskPassesDefaultArgumentsToLauncher()
        {
            var task = new StubbedRunGallioCommand();

            task.SetRunLauncherAction(delegate(TestLauncher launcher)
            {
                Assert.IsFalse(launcher.DoNotRun);
                Assert.IsTrue(launcher.EchoResults);
                Assert.IsTrue(launcher.TestExecutionOptions.FilterSet.IsEmpty);
                Assert.IsInstanceOfType(typeof(CommandLogger), launcher.Logger);
                Assert.IsInstanceOfType(typeof(CommandProgressMonitorProvider), launcher.ProgressMonitorProvider);
                Assert.AreEqual("Reports", launcher.TestProject.ReportDirectory);
                Assert.IsFalse(launcher.TestProject.IsReportDirectorySpecified);
                Assert.AreElementsEqual(new string[] { }, launcher.ReportFormats);
                Assert.AreEqual("test-report-{0}-{1}", launcher.TestProject.ReportNameFormat);
                Assert.IsFalse(launcher.TestProject.IsReportNameFormatSpecified);
                Assert.IsFalse(launcher.ShowReports);
                Assert.AreEqual(ReportArchive.Normal, launcher.TestProject.ReportArchive);
                Assert.IsNull(launcher.RunTimeLimit);

                Assert.AreEqual(StandardTestRunnerFactoryNames.IsolatedProcess, launcher.TestProject.TestRunnerFactoryName);
                Assert.IsFalse(launcher.TestProject.IsTestRunnerFactoryNameSpecified);
                Assert.AreEqual(0, launcher.TestProject.TestRunnerExtensions.Count);
                Assert.AreElementsEqual(new string[] { }, launcher.TestProject.TestRunnerExtensionSpecifications);

                Assert.IsNull(launcher.RuntimeSetup.ConfigurationFilePath);
                Assert.AreEqual(Path.GetDirectoryName(AssemblyUtils.GetAssemblyLocalPath(typeof(RunGallioCommand).Assembly)), launcher.RuntimeSetup.RuntimePath);
                Assert.AreElementsEqual(new string[] { }, launcher.RuntimeSetup.PluginDirectories);

                Assert.AreElementsEqual(new string[] { }, from x in launcher.FilePatterns select x.ToString());
                Assert.AreElementsEqual(new string[] { }, from x in launcher.TestProject.TestPackage.HintDirectories select x.ToString());

                Assert.IsNull(launcher.TestProject.TestPackage.ApplicationBaseDirectory);
                Assert.IsFalse(launcher.TestProject.TestPackage.IsApplicationBaseDirectorySpecified);
                Assert.IsNull(launcher.TestProject.TestPackage.WorkingDirectory);
                Assert.IsFalse(launcher.TestProject.TestPackage.IsWorkingDirectorySpecified);
                Assert.IsFalse(launcher.TestProject.TestPackage.ShadowCopy);
                Assert.IsFalse(launcher.TestProject.TestPackage.IsShadowCopySpecified);
                Assert.IsNull(launcher.TestProject.TestPackage.DebuggerSetup);
                Assert.IsFalse(launcher.TestProject.TestPackage.IsDebuggerSetupSpecified);
                Assert.IsNull(launcher.TestProject.TestPackage.RuntimeVersion);
                Assert.IsFalse(launcher.TestProject.TestPackage.IsRuntimeVersionSpecified);

                Assert.AreEqual(new PropertySet(), launcher.TestRunnerOptions.Properties);
                Assert.AreEqual(new PropertySet(), launcher.ReportFormatterOptions.Properties);

                return(new TestLauncherResult(new Report()));
            });

            task.ExecuteWithMessagePump();
        }
 public IMetadataAccess ResolveAssembly(AssemblyNameInfo name, out FileSystemPath assemblyLocation)
 {
     try
     {
         Assembly assembly = Assembly.Load(name.FullName);
         assemblyLocation = new FileSystemPath((AssemblyUtils.GetAssemblyLocalPath(assembly)));
         return(MetadataProviderFactory.DefaultProvider.GetFromFile(assemblyLocation));
     }
     catch
     {
         assemblyLocation = null;
         return(null);
     }
 }
        private ProcessTask RunPowerShell(string options)
        {
            string executablePath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.System),
                @"windowspowershell\v1.0\powershell.exe");

            string workingDirectory = Path.GetDirectoryName((AssemblyUtils.GetAssemblyLocalPath(GetType().Assembly)));

            ProcessTask task = Tasks.StartProcessTask(executablePath,
                                                      "\"& Add-PSSnapIn Gallio; $DebugPreference = 'Continue'; Run-Gallio 'MbUnit.TestResources.dll' -pd '" +
                                                      RuntimeAccessor.RuntimePath + "' " + options + "\"",
                                                      workingDirectory);

            Assert.IsTrue(task.Run(TimeSpan.FromSeconds(60)), "A timeout occurred.");
            return(task);
        }
Esempio n. 18
0
        private void InstallRegistryKeysForFramework(string frameworkName, AssemblySignature frameworkAssembly, int priority, IProgressMonitor progressMonitor, RegistryKey hiveKey, string rootKeyPath)
        {
            string subKeyName = string.Concat(rootKeyPath, @"\", RunnerRegKeyPrefix, " - ", frameworkName, " (", frameworkAssembly, ")");
            string message    = string.Format("Adding TestDriven.Net runner registry key for framework '{0}'.", frameworkName);

            logger.Log(LogSeverity.Info, message);
            progressMonitor.SetStatus(message);

            using (RegistryKey subKey = hiveKey.CreateSubKey(subKeyName, RegistryKeyPermissionCheck.ReadWriteSubTree))
            {
                subKey.SetValue(null, priority.ToString());
                subKey.SetValue("AssemblyPath", AssemblyUtils.GetAssemblyLocalPath(GetType().Assembly));
                subKey.SetValue("TargetFrameworkAssemblyName", frameworkAssembly.ToString()); // n.b. TDNet supports version ranges in the same format we use
                subKey.SetValue("TypeName", "Gallio.TDNetRunner.GallioTestRunner");
                subKey.SetValue("TypeName_Resident", "Gallio.TDNetRunner.GallioResidentTestRunner");
            }
        }
Esempio n. 19
0
        public void TaskPassesDefaultArgumentsToLauncher()
        {
            var task = new StubbedGallioTask();

            task.SetRunLauncherAction(launcher =>
            {
                Assert.IsFalse(launcher.DoNotRun);
                Assert.IsFalse(launcher.EchoResults);
                Assert.IsTrue(launcher.TestExecutionOptions.FilterSet.IsEmpty);
                Assert.AreEqual(LogSeverity.Important, ((FilteredLogger)launcher.Logger).MinSeverity);
                Assert.IsInstanceOfType(typeof(LogProgressMonitorProvider), launcher.ProgressMonitorProvider);
                Assert.AreEqual("Reports", launcher.TestProject.ReportDirectory);
                Assert.IsFalse(launcher.TestProject.IsReportDirectorySpecified);
                Assert.AreElementsEqual(new string[] { }, launcher.ReportFormats);
                Assert.AreEqual("test-report-{0}-{1}", launcher.TestProject.ReportNameFormat);
                Assert.IsFalse(launcher.TestProject.IsTestRunnerFactoryNameSpecified);
                Assert.IsFalse(launcher.ShowReports);
                Assert.IsNull(launcher.RunTimeLimit);
                Assert.AreEqual(ReportArchive.Normal, launcher.TestProject.ReportArchive);
                Assert.AreEqual(StandardTestRunnerFactoryNames.IsolatedProcess, launcher.TestProject.TestRunnerFactoryName);
                Assert.IsFalse(launcher.TestProject.IsTestRunnerFactoryNameSpecified);
                Assert.AreEqual(1, launcher.TestProject.TestRunnerExtensions.Count);
                Assert.IsInstanceOfType(typeof(TaskLogExtension), launcher.TestProject.TestRunnerExtensions[0]);
                Assert.AreElementsEqual(new string[] { }, launcher.TestProject.TestRunnerExtensionSpecifications);
                Assert.IsNull(launcher.RuntimeSetup.ConfigurationFilePath);
                Assert.AreEqual(Path.GetDirectoryName(AssemblyUtils.GetAssemblyLocalPath(typeof(Gallio).Assembly)), launcher.RuntimeSetup.RuntimePath);
                Assert.AreElementsEqual(new string[] { }, launcher.RuntimeSetup.PluginDirectories);
                Assert.AreElementsEqual(new string[] { }, from x in launcher.FilePatterns select x.ToString());
                Assert.AreElementsEqual(new string[] { }, from x in launcher.TestProject.TestPackage.HintDirectories select x.ToString());
                Assert.IsNull(launcher.TestProject.TestPackage.ApplicationBaseDirectory);
                Assert.IsFalse(launcher.TestProject.TestPackage.IsApplicationBaseDirectorySpecified);
                Assert.IsNull(launcher.TestProject.TestPackage.WorkingDirectory);
                Assert.IsFalse(launcher.TestProject.TestPackage.IsWorkingDirectorySpecified);
                Assert.IsFalse(launcher.TestProject.TestPackage.ShadowCopy);
                Assert.IsNull(launcher.TestProject.TestPackage.DebuggerSetup);
                Assert.IsNull(launcher.TestProject.TestPackage.RuntimeVersion);
                Assert.IsFalse(launcher.TestProject.TestPackage.IsRuntimeVersionSpecified);
                Assert.AreEqual(new PropertySet(), launcher.TestRunnerOptions.Properties);
                Assert.AreEqual(new PropertySet(), launcher.ReportFormatterOptions.Properties);
                var result = new TestLauncherResult(new Report());
                result.SetResultCode(ResultCode.Success);
                return(result);
            });

            Assert.IsTrue(task.InternalExecute());
        }
        private ProcessTask RunEcho(string options)
        {
            string testAssemblyPath = AssemblyUtils.GetAssemblyLocalPath(typeof(SimpleTest).Assembly);
            string workingDirectory = Path.GetDirectoryName((AssemblyUtils.GetAssemblyLocalPath(GetType().Assembly)));
#if DEBUG
            string executablePath = Path.Combine(workingDirectory, "Gallio.Echo.exe");
#else
            string executablePath = Path.Combine(RuntimeAccessor.Instance.GetRuntimeSetup().RuntimePath, "Gallio.Echo.exe");
#endif

            ProcessTask task = Tasks.StartProcessTask(executablePath,
                "\"" + testAssemblyPath + "\" /pd:\"" + RuntimeAccessor.RuntimePath + "\" " + options,
                workingDirectory);

            Assert.IsTrue(task.Run(TimeSpan.FromSeconds(60)), "A timeout occurred.");
            return task;
        }
Esempio n. 21
0
        /// <summary>
        /// Gets the location of a source file that contains the declaration of a method, or
        /// unknown if not available.
        /// </summary>
        /// <param name="method">The method.</param>
        /// <returns>The source location, or <see cref="CodeLocation.Unknown" /> if unknown.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="method"/> is null.</exception>
        public static CodeLocation GetSourceLocation(MethodBase method)
        {
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }

            Assembly assembly     = method.DeclaringType.Assembly;
            string   assemblyPath = AssemblyUtils.GetAssemblyLocation(assembly); // use the shadow-copied location if applicable

            if (assemblyPath == null)
            {
                return(CodeLocation.Unknown);
            }

            if (AppDomain.CurrentDomain.ShadowCopyFiles)
            {
                try
                {
                    string pdbPath = Path.ChangeExtension(assemblyPath, @".pdb");
                    if (!File.Exists(pdbPath))
                    {
                        string originalAssemblyPath = AssemblyUtils.GetAssemblyLocalPath(assembly);
                        if (originalAssemblyPath == null)
                        {
                            return(CodeLocation.Unknown);
                        }

                        string originalPdbPath = Path.ChangeExtension(originalAssemblyPath, @".pdb");
                        if (!File.Exists(originalPdbPath))
                        {
                            return(CodeLocation.Unknown);
                        }

                        File.Copy(originalPdbPath, pdbPath);
                    }
                }
                catch (IOException)
                {
                    return(CodeLocation.Unknown);
                }
            }

            return(Resolver.GetSourceLocationForMethod(assemblyPath, method.MetadataToken));
        }
Esempio n. 22
0
        public void RunAssemblyPassesCorrectOptionsToTheLauncher()
        {
            StubbedLocalTestRunner tr = new StubbedLocalTestRunner();

            Assembly assembly     = typeof(TDNetAddInTests).Assembly;
            string   assemblyPath = AssemblyUtils.GetAssemblyLocalPath(assembly);

            tr.SetRunLauncherAction(delegate(TestLauncher launcher)
            {
                AssertTestLauncherOptions(launcher, assemblyPath, "*");

                return(new TestLauncherResult(new Report()));
            });

            FacadeOptions facadeOptions = new FacadeOptions();

            tr.Run(MockRepository.GenerateStub <IFacadeTestListener>(), assemblyPath, null, facadeOptions);
        }
Esempio n. 23
0
        /// <summary>
        /// Gets the report generator executable path.
        /// </summary>
        /// <returns>The report generator executable path.</returns>
        private static string GetReportGeneratorExePath()
        {
            string pluginDir    = Path.GetDirectoryName(AssemblyUtils.GetAssemblyLocalPath(typeof(PartCoverTool).Assembly));
            string partcoverDir = Path.Combine(pluginDir, @"libs\ReportGenerator\ReportGenerator.exe");

            if (File.Exists(partcoverDir))
            {
                return(partcoverDir);
            }
#if DEBUG
            partcoverDir = Path.GetFullPath(Path.Combine(pluginDir, @"..\..\libs\ReportGenerator\ReportGenerator.exe"));
            if (File.Exists(partcoverDir))
            {
                return(partcoverDir);
            }
#endif
            return(null);
        }
        public IMetadataAccess ResolveAssembly(AssemblyName name, out string assemblyLocation)
        {
            try
            {
                Assembly assembly = Assembly.Load(name);
                assemblyLocation = AssemblyUtils.GetAssemblyLocalPath(assembly);
#if RESHARPER_31 || RESHARPER_40 || RESHARPER_41
                return(MetadataProvider.GetFromFile(assemblyLocation));
#else
                return(MetadataProvider.Instance.GetFromFile(assemblyLocation));
#endif
            }
            catch
            {
                assemblyLocation = null;
                return(null);
            }
        }
        public static Solution OpenSolutionIfNeeded()
        {
            string solutionPath = Path.Combine(Path.GetDirectoryName(
                                                   AssemblyUtils.GetAssemblyLocalPath(typeof(VisualStudioTestHarness).Assembly)), @"..\TestSolution.sln");

            Solution solution = null;

            visualStudio.Call(dte =>
            {
                if (!dte.Solution.IsOpen)
                {
                    dte.Solution.Open(solutionPath);
                }

                solution = dte.Solution;
            });

            return(solution);
        }
Esempio n. 26
0
        public void RunReturnsCorrectResultCode(int resultCode, FacadeTestRunState expectedRunState)
        {
            StubbedLocalTestRunner tr = new StubbedLocalTestRunner();

            Assembly assembly     = typeof(TDNetAddInTests).Assembly;
            string   assemblyPath = AssemblyUtils.GetAssemblyLocalPath(assembly);

            tr.SetRunLauncherAction(delegate
            {
                TestLauncherResult result = new TestLauncherResult(new Report());
                result.SetResultCode(resultCode);
                return(result);
            });

            FacadeOptions      facadeOptions = new FacadeOptions();
            FacadeTestRunState runResult     = tr.Run(MockRepository.GenerateStub <IFacadeTestListener>(), assemblyPath, null, facadeOptions);

            Assert.AreEqual(expectedRunState, runResult);
        }
Esempio n. 27
0
        /// <summary>
        /// Gets the XML documentation for a member.
        /// </summary>
        /// <param name="member">The member.</param>
        /// <returns>The XML documentation for the member, or null if none available.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="member"/> is null.</exception>
        public static string GetXmlDocumentation(MemberInfo member)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member");
            }

            Type   type         = member as Type ?? member.DeclaringType;
            string assemblyPath = AssemblyUtils.GetAssemblyLocalPath(type.Assembly);

            if (assemblyPath == null)
            {
                return(null);
            }

            string memberId = FormatId(member);

            return(Resolver.GetXmlDocumentation(assemblyPath, memberId));
        }
Esempio n. 28
0
        public override string GetInstallDir()
        {
            string pluginDir = Path.GetDirectoryName(AssemblyUtils.GetAssemblyLocalPath(typeof(NCoverV1Tool).Assembly));
            string ncoverDir = Path.Combine(pluginDir, @"libs\NCover");

            if (Directory.Exists(ncoverDir))
            {
                return(ncoverDir);
            }

#if DEBUG
            ncoverDir = Path.GetFullPath(Path.Combine(pluginDir, @"..\..\libs\NCover"));
            if (Directory.Exists(ncoverDir))
            {
                return(ncoverDir);
            }
#endif

            return(null);
        }
Esempio n. 29
0
        public void RunMemberWithTypePassesCorrectOptionsToTheLauncher()
        {
            StubbedLocalTestRunner tr = new StubbedLocalTestRunner();

            Type     type         = typeof(TDNetAddInTests);
            Assembly assembly     = type.Assembly;
            string   assemblyPath = AssemblyUtils.GetAssemblyLocalPath(assembly);

            tr.SetRunLauncherAction(delegate(TestLauncher launcher)
            {
                AssertTestLauncherOptions(launcher, assemblyPath,
                                          string.Format("Type: {0}", type.FullName));

                return(new TestLauncherResult(new Report()));
            });

            FacadeOptions facadeOptions = new FacadeOptions();

            tr.Run(MockRepository.GenerateStub <IFacadeTestListener>(), assemblyPath, "T:" + type.FullName, facadeOptions);
        }
Esempio n. 30
0
        public void RunNamespacePassesCorrectOptionsToTheLauncher()
        {
            StubbedLocalTestRunner tr = new StubbedLocalTestRunner();

            Assembly assembly     = typeof(TDNetAddInTests).Assembly;
            string   assemblyPath = AssemblyUtils.GetAssemblyLocalPath(assembly);
            string   @namespace   = "Foo";

            tr.SetRunLauncherAction(delegate(TestLauncher launcher)
            {
                AssertTestLauncherOptions(launcher, AssemblyUtils.GetAssemblyLocalPath(assembly),
                                          string.Format("Namespace: {0}", @namespace));

                return(new TestLauncherResult(new Report()));
            });

            FacadeOptions facadeOptions = new FacadeOptions();

            tr.Run(MockRepository.GenerateStub <IFacadeTestListener>(), assemblyPath, "N:" + @namespace, facadeOptions);
        }