From cc7213f450a4be7b45e998a095dec2a4c283ad68 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 6 Aug 2011 19:51:34 +0200 Subject: [PATCH] Fixed codeplex issue 6449: plugin failure without XUnit runner --- .../XUnit/SilverlightXunitTestFileExplorer.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/AgUnit.Runner.Resharper60/UnitTestProvider/XUnit/SilverlightXunitTestFileExplorer.cs b/src/AgUnit.Runner.Resharper60/UnitTestProvider/XUnit/SilverlightXunitTestFileExplorer.cs index f3350fb..1f6bd01 100644 --- a/src/AgUnit.Runner.Resharper60/UnitTestProvider/XUnit/SilverlightXunitTestFileExplorer.cs +++ b/src/AgUnit.Runner.Resharper60/UnitTestProvider/XUnit/SilverlightXunitTestFileExplorer.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Reflection; +using AgUnit.Runner.Resharper60.UnitTestFramework.Silverlight; using JetBrains.Application; using JetBrains.Metadata.Utils; using JetBrains.ProjectModel; @@ -19,16 +20,26 @@ public class SilverlightXunitTestFileExplorer : IUnitTestFileExplorer { private const string ProviderId = "xUnit"; private static readonly Type XunitPsiFileExplorerType = Type.GetType("XunitContrib.Runner.ReSharper.UnitTestProvider.XunitPsiFileExplorer, xunitcontrib.runner.resharper.provider.6.0"); - + private readonly IUnitTestProvider provider; + private readonly bool xUnitInstalled = true; public SilverlightXunitTestFileExplorer(ISolution solution) { provider = UnitTestManager.GetInstance(solution).GetProvider(ProviderId); + + if (provider == null) + { + xUnitInstalled = false; + provider = UnitTestManager.GetInstance(solution).GetProvider(SilverlightUnitTestProvider.RunnerId); + } } public void ExploreFile(IFile psiFile, UnitTestElementLocationConsumer consumer, CheckForInterrupt interrupted) { + if (!xUnitInstalled) + return; + if (provider == null) return; @@ -42,7 +53,7 @@ public void ExploreFile(IFile psiFile, UnitTestElementLocationConsumer consumer, if (project.GetAssemblyReferences().Any(IsSilverlightMscorlib)) return; - var psiFileExplorer = (IRecursiveElementProcessor)Activator.CreateInstance(XunitPsiFileExplorerType, + var psiFileExplorer = (IRecursiveElementProcessor)Activator.CreateInstance(XunitPsiFileExplorerType, provider, consumer, psiFile, interrupted); psiFile.ProcessDescendants(psiFileExplorer);