Skip to content

Commit

Permalink
Fixed codeplex issue 6449: plugin failure without XUnit runner
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Aug 6, 2011
1 parent 88bbd9e commit cc7213f
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand All @@ -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);
Expand Down

0 comments on commit cc7213f

Please sign in to comment.