Skip to content
Browse files

Added remaining missing classes based on nUnit test runner

  • Loading branch information...
1 parent ec7cbe4 commit c10a7192d5ec30b455da7297c035b19fe2191147 chris.nicola committed
View
27 Source/Machine.Specifications.ReSharperRunner.6.0/Explorers/MSpecTestMetadataExplorer.cs
@@ -0,0 +1,27 @@
+using JetBrains.Metadata.Reader.API;
+using JetBrains.ProjectModel;
+using JetBrains.ReSharper.UnitTestFramework;
+
+namespace Machine.Specifications.ReSharperRunner.Explorers
+{
+ [MetadataUnitTestExplorer]
+ public class MSpecTestMetadataExplorer : IUnitTestMetadataExplorer
+ {
+ readonly MSpecUnitTestProvider _provider;
+
+ public MSpecTestMetadataExplorer(MSpecUnitTestProvider provider)
+ {
+ _provider = provider;
+ }
+
+ public void ExploreAssembly(IProject project, IMetadataAssembly assembly, UnitTestElementConsumer consumer)
+ {
+ new AssemblyExplorer(_provider, assembly, project, consumer).Explore();
+ }
+
+ public IUnitTestProvider Provider
+ {
+ get { return _provider; }
+ }
+ }
+}
View
28 Source/Machine.Specifications.ReSharperRunner.6.0/Explorers/MspecTestFileExplorer.cs
@@ -0,0 +1,28 @@
+using JetBrains.Application;
+using JetBrains.ReSharper.Psi;
+using JetBrains.ReSharper.Psi.Tree;
+using JetBrains.ReSharper.UnitTestFramework;
+
+namespace Machine.Specifications.ReSharperRunner.Explorers
+{
+ [FileUnitTestExplorer]
+ public class MspecTestFileExplorer : IUnitTestFileExplorer
+ {
+ MSpecUnitTestProvider _provider;
+
+ public MspecTestFileExplorer(MSpecUnitTestProvider provider)
+ {
+ _provider = provider;
+ }
+
+ public void ExploreFile(IFile psiFile, UnitTestElementLocationConsumer consumer, CheckForInterrupt interrupted)
+ {
+ if ((psiFile.Language.Name == "CSHARP") || (psiFile.Language.Name == "VBASIC"))
+ {
+ psiFile.ProcessDescendants(new FileExplorer(_provider, consumer, psiFile, interrupted));
+ }
+ }
+
+ public IUnitTestProvider Provider { get { return _provider; }}
+ }
+}
View
22 Source/Machine.Specifications.ReSharperRunner.6.0/MSpecUnitTestPresenter.cs
@@ -0,0 +1,22 @@
+using JetBrains.CommonControls;
+using JetBrains.ReSharper.UnitTestFramework;
+using JetBrains.TreeModels;
+using JetBrains.UI.TreeView;
+
+using Machine.Specifications.ReSharperRunner.Presentation;
+
+namespace Machine.Specifications.ReSharperRunner
+{
+ [UnitTestPresenter]
+ public class MSpecUnitTestPresenter : IUnitTestPresenter
+ {
+ Presenter _presenter;
+
+ public MSpecUnitTestPresenter() { _presenter = new Presenter(); }
+
+ public void Present(IUnitTestElement element, IPresentableItem item, TreeModelNode node, PresentationState state)
+ {
+ _presenter.UpdateItem(element, node, item, state);
+ }
+ }
+}
View
111 Source/Machine.Specifications.ReSharperRunner.6.0/MSpecUnitTestProvider.cs
@@ -0,0 +1,111 @@
+using System;
+using System.Diagnostics;
+using System.Drawing;
+using System.Xml;
+
+using JetBrains.ProjectModel;
+using JetBrains.ReSharper.Psi;
+using JetBrains.ReSharper.Psi.Caches;
+using JetBrains.ReSharper.TaskRunnerFramework;
+using JetBrains.ReSharper.UnitTestFramework;
+
+using Machine.Specifications.ReSharperRunner.Presentation;
+using Machine.Specifications.ReSharperRunner.Properties;
+using Machine.Specifications.ReSharperRunner.Runners;
+
+namespace Machine.Specifications.ReSharperRunner
+{
+ [UnitTestProvider]
+ public class MSpecUnitTestProvider : IUnitTestProvider
+ {
+ const string ProviderId = "Machine.Specifications";
+ readonly UnitTestElementComparer _unitTestElementComparer = new UnitTestElementComparer();
+
+ public MSpecUnitTestProvider(ISolution solution, PsiModuleManager psiModuleManager, CacheManager cacheManager)
+ {
+ Solution = solution;
+ PsiModuleManager = psiModuleManager;
+ CacheManager = cacheManager;
+ Debug.Listeners.Add(new DefaultTraceListener());
+ }
+
+ public PsiModuleManager PsiModuleManager { get; private set; }
+ public CacheManager CacheManager { get; private set; }
+
+ public string ID
+ {
+ get { return ProviderId; }
+ }
+
+ public string Name
+ {
+ get { return ID; }
+ }
+
+ public IUnitTestElement DeserializeElement(XmlElement parent, IUnitTestElement parentElement)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Image Icon
+ {
+ get { return Resources.Logo; }
+ }
+
+ public ISolution Solution { get; private set; }
+
+ public void ExploreSolution(ISolution solution, UnitTestElementConsumer consumer)
+ {
+ }
+
+ public void ExploreExternal(UnitTestElementConsumer consumer)
+ {
+ }
+
+ public RemoteTaskRunnerInfo GetTaskRunnerInfo()
+ {
+ return new RemoteTaskRunnerInfo(typeof(RecursiveMSpecTaskRunner));
+ }
+
+ public int CompareUnitTestElements(IUnitTestElement x, IUnitTestElement y)
+ {
+ return _unitTestElementComparer.Compare(x, y);
+ }
+
+ public bool IsElementOfKind(IUnitTestElement element, UnitTestElementKind elementKind)
+ {
+ switch (elementKind)
+ {
+ case UnitTestElementKind.Test:
+ return element is ContextSpecificationElement;
+ case UnitTestElementKind.TestContainer:
+ return element is ContextElement || element is BehaviorElement;
+ }
+
+ return false;
+ }
+
+ public bool IsElementOfKind(IDeclaredElement declaredElement, UnitTestElementKind elementKind)
+ {
+ switch (elementKind)
+ {
+ case UnitTestElementKind.Test:
+ return declaredElement.IsSpecification();
+ case UnitTestElementKind.TestContainer:
+ return declaredElement.IsContext() || declaredElement.IsBehavior();
+ }
+
+ return false;
+ }
+
+ public bool IsSupported(IHostProvider hostProvider)
+ {
+ return true;
+ }
+
+ public void SerializeElement(XmlElement parent, IUnitTestElement element)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
View
6 ...hine.Specifications.ReSharperRunner.6.0/Machine.Specifications.ReSharperRunner.6.0.csproj
@@ -195,20 +195,24 @@
<Compile Include="..\VersionInfo.cs">
<Link>Properties\VersionInfo.cs</Link>
</Compile>
+ <Compile Include="Explorers\MspecTestFileExplorer.cs" />
+ <Compile Include="Explorers\MSpecTestMetadataExplorer.cs" />
<Compile Include="MetadataExtensions.cs" />
+ <Compile Include="MSpecUnitTestPresenter.cs" />
+ <Compile Include="MSpecUnitTestProvider.cs" />
<Compile Include="Presentation\BehaviorElement.cs" />
<Compile Include="Presentation\BehaviorSpecificationElement.cs" />
<Compile Include="Presentation\ContextElement.cs" />
<Compile Include="Presentation\ContextSpecificationElement.cs" />
<Compile Include="Presentation\Element.cs" />
<Compile Include="Presentation\FieldElement.cs" />
+ <Compile Include="Presentation\Presenter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<DependentUpon>Resources.resx</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
- <Compile Include="Tasks\MSpecUnitTestProvider.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Machine.Specifications\Machine.Specifications.csproj">
View
415 Source/Machine.Specifications.ReSharperRunner.6.0/Presentation/Element.cs
@@ -5,6 +5,7 @@
using JetBrains.Application;
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Psi;
+using JetBrains.ReSharper.Psi.Caches;
using JetBrains.ReSharper.Psi.Tree;
using JetBrains.ReSharper.UnitTestFramework;
using JetBrains.Util;
@@ -13,233 +14,235 @@
namespace Machine.Specifications.ReSharperRunner.Presentation
{
- abstract class Element : IUnitTestElement
+ abstract class Element : IUnitTestElement
+ {
+ readonly string _declaringTypeName;
+ readonly ProjectModelElementEnvoy _projectEnvoy;
+ readonly MSpecUnitTestProvider _provider;
+ readonly UnitTestTaskFactory _taskFactory;
+
+ protected Element(MSpecUnitTestProvider provider,
+ Element parent,
+ ProjectModelElementEnvoy projectEnvoy,
+ string declaringTypeName,
+ bool isIgnored)
{
- readonly MSpecUnitTestProvider _provider;
- readonly string _declaringTypeName;
- readonly ProjectModelElementEnvoy _projectEnvoy;
- readonly UnitTestTaskFactory _taskFactory;
-
- protected Element(MSpecUnitTestProvider provider,
- Element parent,
- ProjectModelElementEnvoy projectEnvoy,
- string declaringTypeName,
- bool isIgnored)
- {
- if (projectEnvoy == null && !Shell.Instance.IsTestShell)
- {
- throw new ArgumentNullException("project");
- }
-
- if (declaringTypeName == null)
- {
- throw new ArgumentNullException("declaringTypeName");
- }
-
- if (projectEnvoy != null)
- {
- _projectEnvoy = projectEnvoy;
- }
-
- _provider = provider;
- _declaringTypeName = declaringTypeName;
-
- if (isIgnored)
- {
- ExplicitReason = "Ignored";
- }
-
- TypeName = declaringTypeName;
- Parent = parent;
-
- Children = new List<IUnitTestElement>();
- State = UnitTestElementState.Valid;
- _taskFactory = new UnitTestTaskFactory(_provider.ID);
- }
+ if (projectEnvoy == null && !Shell.Instance.IsTestShell)
+ {
+ throw new ArgumentNullException("project");
+ }
+
+ if (declaringTypeName == null)
+ {
+ throw new ArgumentNullException("declaringTypeName");
+ }
+
+ if (projectEnvoy != null)
+ {
+ _projectEnvoy = projectEnvoy;
+ }
+
+ _provider = provider;
+ _declaringTypeName = declaringTypeName;
+
+ if (isIgnored)
+ {
+ ExplicitReason = "Ignored";
+ }
+
+ TypeName = declaringTypeName;
+ Parent = parent;
+
+ Children = new List<IUnitTestElement>();
+ State = UnitTestElementState.Valid;
+ _taskFactory = new UnitTestTaskFactory(_provider.ID);
+ }
- public string TypeName { get; protected set; }
- public abstract string Kind { get; }
- public abstract IEnumerable<UnitTestElementCategory> Categories { get; }
- public string ExplicitReason { get; private set; }
+ public string TypeName { get; protected set; }
+ public abstract string Kind { get; }
+ public abstract IEnumerable<UnitTestElementCategory> Categories { get; }
+ public string ExplicitReason { get; private set; }
- public string Id
- {
- get { return TypeName; }
- }
+ public string Id
+ {
+ get { return TypeName; }
+ }
- public IUnitTestProvider Provider
- {
- get { return _provider; }
- }
+ public IUnitTestProvider Provider
+ {
+ get { return _provider; }
+ }
- public IUnitTestElement Parent { get; set; }
- public ICollection<IUnitTestElement> Children { get; private set; }
- public abstract string ShortName { get; }
+ public IUnitTestElement Parent { get; set; }
+ public ICollection<IUnitTestElement> Children { get; private set; }
+ public abstract string ShortName { get; }
- public bool Explicit
- {
- get { return false; }
- }
+ public bool Explicit
+ {
+ get { return false; }
+ }
- public UnitTestElementState State { get; set; }
+ public UnitTestElementState State { get; set; }
- public virtual string GetTitlePrefix()
- {
- return String.Empty;
- }
+ public IProject GetProject()
+ {
+ return _projectEnvoy.GetValidProjectElement() as IProject;
+ }
- public IProject GetProject()
- {
- return _projectEnvoy.GetValidProjectElement() as IProject;
- }
+ public UnitTestNamespace GetNamespace()
+ {
+ return new UnitTestNamespace(new ClrTypeName(_declaringTypeName).GetNamespaceName());
+ }
- protected ITypeElement GetDeclaredType()
+ public UnitTestElementDisposition GetDisposition()
+ {
+ IDeclaredElement element = GetDeclaredElement();
+ if (element == null || !element.IsValid())
+ {
+ return UnitTestElementDisposition.InvalidDisposition;
+ }
+
+ var locations = new List<UnitTestElementLocation>();
+ element.GetDeclarations().ForEach(declaration =>
+ {
+ IFile file = declaration.GetContainingFile();
+ if (file != null)
{
- var project = GetProject();
- if (project == null)
- {
- return null;
- }
-
- var psiModule = _provider.PsiModuleManager.GetPrimaryPsiModule(project);
- if (psiModule == null)
- {
- return null;
- }
-
- var declarationsCache = _provider.CacheManager.GetDeclarationsCache(psiModule, true, true);
- return declarationsCache.GetTypeElementByCLRName(_declaringTypeName);
+ locations.Add(new UnitTestElementLocation(file.GetSourceFile().ToProjectFile(),
+ declaration.GetNameDocumentRange().TextRange,
+ declaration.GetDocumentRange().TextRange));
}
+ });
- public string GetTypeClrName()
- {
- return _declaringTypeName;
- }
+ return new UnitTestElementDisposition(locations, this);
+ }
- public UnitTestNamespace GetNamespace()
- {
- return new UnitTestNamespace(new ClrTypeName(_declaringTypeName).GetNamespaceName());
- }
+ public bool Equals(IUnitTestElement other)
+ {
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ if (other.GetType() == GetType())
+ {
+ var element = (Element) other;
+ return other.ShortName == ShortName && other.Provider == Provider
+ && Equals(element._projectEnvoy, _projectEnvoy) &&
+ element._declaringTypeName == _declaringTypeName;
+ }
+ return false;
+ }
- public UnitTestElementDisposition GetDisposition()
- {
- var element = GetDeclaredElement();
- if (element == null || !element.IsValid())
- {
- return UnitTestElementDisposition.InvalidDisposition;
- }
-
- var locations = new List<UnitTestElementLocation>();
- element.GetDeclarations().ForEach(declaration =>
- {
- var file = declaration.GetContainingFile();
- if (file != null)
- {
- locations.Add(new UnitTestElementLocation(file.GetSourceFile().ToProjectFile(),
- declaration.GetNameDocumentRange().TextRange,
- declaration.GetDocumentRange().TextRange));
- }
- });
-
- return new UnitTestElementDisposition(locations, this);
- }
+ public abstract string GetPresentation();
+ public abstract IDeclaredElement GetDeclaredElement();
- public override bool Equals(object obj)
- {
- var other = (Element) obj;
- return Equals(other._projectEnvoy, _projectEnvoy) && other._declaringTypeName == _declaringTypeName;
- }
+ public IEnumerable<IProjectFile> GetProjectFiles()
+ {
+ ITypeElement declaredType = GetDeclaredType();
+ if (declaredType == null)
+ {
+ return EmptyArray<IProjectFile>.Instance;
+ }
- public override int GetHashCode()
- {
- var result = 0;
- result = 29 * result + _projectEnvoy.GetHashCode();
- result = 29 * result + _declaringTypeName.GetHashCode();
- return result;
- }
+ return declaredType.GetSourceFiles().Select(x => x.ToProjectFile());
+ }
- public bool Equals(IUnitTestElement other)
- {
- if (ReferenceEquals(this, other))
- {
- return true;
- }
-
- if (other.GetType() == GetType())
- {
- var element = (Element) other;
- return other.ShortName == ShortName && other.Provider == Provider
- && Equals(element._projectEnvoy, _projectEnvoy) &&
- element._declaringTypeName == _declaringTypeName;
- }
- return false;
- }
+ public IList<UnitTestTask> GetTaskSequence(IEnumerable<IUnitTestElement> explicitElements)
+ {
+ if (this is ContextSpecificationElement)
+ {
+ var contextSpecification = this as ContextSpecificationElement;
+ ContextElement context = contextSpecification.Context;
+
+ return new List<UnitTestTask>
+ {
+ _taskFactory.CreateAssemblyLoadTask(context),
+ _taskFactory.CreateContextTask(context, explicitElements.Contains(context)),
+ _taskFactory.CreateContextSpecificationTask(context,
+ contextSpecification,
+ explicitElements.Contains(contextSpecification))
+ };
+ }
+
+ if (this is BehaviorElement)
+ {
+ var behavior = this as BehaviorElement;
+ ContextElement context = behavior.Context;
+
+ return new List<UnitTestTask>
+ {
+ _taskFactory.CreateAssemblyLoadTask(context),
+ _taskFactory.CreateContextTask(context, explicitElements.Contains(context)),
+ _taskFactory.CreateBehaviorTask(context, behavior, explicitElements.Contains(behavior))
+ };
+ }
+
+ if (this is BehaviorSpecificationElement)
+ {
+ var behaviorSpecification = this as BehaviorSpecificationElement;
+ BehaviorElement behavior = behaviorSpecification.Behavior;
+ ContextElement context = behavior.Context;
+
+ return new List<UnitTestTask>
+ {
+ _taskFactory.CreateAssemblyLoadTask(context),
+ _taskFactory.CreateContextTask(context, explicitElements.Contains(context)),
+ _taskFactory.CreateBehaviorTask(context, behavior, explicitElements.Contains(behavior)),
+ _taskFactory.CreateBehaviorSpecificationTask(context,
+ behaviorSpecification,
+ explicitElements.Contains(behaviorSpecification))
+ };
+ }
+
+ if (this is ContextElement)
+ {
+ return EmptyArray<UnitTestTask>.Instance;
+ }
+
+ throw new ArgumentException(String.Format("Element is not a Machine.Specifications element: '{0}'", this));
+ }
- public abstract string GetPresentation();
- public abstract IDeclaredElement GetDeclaredElement();
+ public virtual string GetTitlePrefix()
+ {
+ return String.Empty;
+ }
- public IEnumerable<IProjectFile> GetProjectFiles() {
- ITypeElement declaredType = GetDeclaredType();
- if (declaredType == null) {
- return EmptyArray<IProjectFile>.Instance;
- }
+ protected ITypeElement GetDeclaredType()
+ {
+ IProject project = GetProject();
+ if (project == null)
+ {
+ return null;
+ }
+
+ IPsiModule psiModule = _provider.PsiModuleManager.GetPrimaryPsiModule(project);
+ if (psiModule == null)
+ {
+ return null;
+ }
+
+ IDeclarationsCache declarationsCache = _provider.CacheManager.GetDeclarationsCache(psiModule, true, true);
+ return declarationsCache.GetTypeElementByCLRName(_declaringTypeName);
+ }
- return declaredType.GetSourceFiles().Select(x => x.ToProjectFile());
- }
+ public string GetTypeClrName()
+ {
+ return _declaringTypeName;
+ }
- public IList<UnitTestTask> GetTaskSequence(IEnumerable<IUnitTestElement> explicitElements)
- {
- if (this is ContextSpecificationElement)
- {
- var contextSpecification = this as ContextSpecificationElement;
- var context = contextSpecification.Context;
-
- return new List<UnitTestTask>
- {
- _taskFactory.CreateAssemblyLoadTask(context),
- _taskFactory.CreateContextTask(context, explicitElements.Contains(context)),
- _taskFactory.CreateContextSpecificationTask(context,
- contextSpecification,
- explicitElements.Contains(contextSpecification))
- };
- }
-
- if (this is BehaviorElement)
- {
- var behavior = this as BehaviorElement;
- var context = behavior.Context;
-
- return new List<UnitTestTask>
- {
- _taskFactory.CreateAssemblyLoadTask(context),
- _taskFactory.CreateContextTask(context, explicitElements.Contains(context)),
- _taskFactory.CreateBehaviorTask(context, behavior, explicitElements.Contains(behavior))
- };
- }
-
- if (this is BehaviorSpecificationElement)
- {
- var behaviorSpecification = this as BehaviorSpecificationElement;
- var behavior = behaviorSpecification.Behavior;
- var context = behavior.Context;
-
- return new List<UnitTestTask>
- {
- _taskFactory.CreateAssemblyLoadTask(context),
- _taskFactory.CreateContextTask(context, explicitElements.Contains(context)),
- _taskFactory.CreateBehaviorTask(context, behavior, explicitElements.Contains(behavior)),
- _taskFactory.CreateBehaviorSpecificationTask(context,
- behaviorSpecification,
- explicitElements.Contains(behaviorSpecification))
- };
- }
-
- if (this is ContextElement)
- {
- return EmptyArray<UnitTestTask>.Instance;
- }
-
- throw new ArgumentException(String.Format("Element is not a Machine.Specifications element: '{0}'", this));
- }
+ public override bool Equals(object obj)
+ {
+ var other = (Element) obj;
+ return Equals(other._projectEnvoy, _projectEnvoy) && other._declaringTypeName == _declaringTypeName;
+ }
+
+ public override int GetHashCode()
+ {
+ int result = 0;
+ result = 29 * result + _projectEnvoy.GetHashCode();
+ result = 29 * result + _declaringTypeName.GetHashCode();
+ return result;
}
+ }
}
View
118 Source/Machine.Specifications.ReSharperRunner.6.0/Presentation/Presenter.cs
@@ -0,0 +1,118 @@
+using System.Drawing;
+
+using JetBrains.CommonControls;
+using JetBrains.ReSharper.Features.Common.TreePsiBrowser;
+using JetBrains.ReSharper.UnitTestExplorer;
+using JetBrains.ReSharper.UnitTestFramework;
+using JetBrains.ReSharper.UnitTestFramework.UI;
+using JetBrains.TreeModels;
+using JetBrains.UI.TreeView;
+
+namespace Machine.Specifications.ReSharperRunner.Presentation
+{
+ class Presenter : TreeModelBrowserPresenter
+ {
+ public Presenter()
+ {
+ Present<ContextElement>(PresentContext);
+ Present<FieldElement>(PresentSpecification);
+ Present<BehaviorElement>(PresentBehavior);
+ Present<BehaviorSpecificationElement>(PresentBehaviorSpecification);
+ }
+
+ protected virtual void PresentContext(ContextElement element,
+ IPresentableItem item,
+ TreeModelNode modelNode,
+ PresentationState state)
+ {
+ PresentItem(item, element, state, UnitTestElementImage.TestContainer);
+ }
+
+ protected virtual void PresentSpecification(FieldElement element,
+ IPresentableItem item,
+ TreeModelNode modelNode,
+ PresentationState state)
+ {
+ PresentItem(item, element, state, UnitTestElementImage.Test);
+ }
+
+ protected virtual void PresentBehavior(BehaviorElement element,
+ IPresentableItem item,
+ TreeModelNode modelNode,
+ PresentationState state)
+ {
+ PresentItem(item, element, state, UnitTestElementImage.TestContainer);
+ }
+
+ protected virtual void PresentBehaviorSpecification(BehaviorSpecificationElement element,
+ IPresentableItem item,
+ TreeModelNode modelNode,
+ PresentationState state)
+ {
+ PresentItem(item, element, state, UnitTestElementImage.Test);
+ }
+
+ static void PresentItem(IPresentableItem item, Element element, PresentationState state, UnitTestElementImage type)
+ {
+ item.RichText = element.GetPresentation();
+
+ SetTextColor(item, element);
+ SetImage(item, state, type);
+ }
+
+ static void SetTextColor(IPresentableItem item, Element element)
+ {
+ if (element.Explicit)
+ {
+ item.RichText.SetForeColor(SystemColors.GrayText);
+ }
+
+ item.RichText.SetForeColor(SystemColors.GrayText, 0, element.GetTitlePrefix().Length);
+ }
+
+ static void SetImage(IPresentableItem item, PresentationState state, UnitTestElementImage imageType)
+ {
+ Image stateImage = UnitTestIconManager.GetStateImage(state);
+ Image typeImage = UnitTestIconManager.GetStandardImage(imageType);
+
+ if (stateImage != null)
+ {
+ item.Images.Add(stateImage);
+ }
+ else if (typeImage != null)
+ {
+ item.Images.Add(typeImage);
+ }
+ }
+
+ protected override bool IsNaturalParent(object parentValue, object childValue)
+ {
+ var @namespace = parentValue as UnitTestNamespace;
+ var context = childValue as ContextElement;
+
+ if (context != null && @namespace != null)
+ {
+ return @namespace.Equals(context.GetNamespace());
+ }
+
+ return base.IsNaturalParent(parentValue, childValue);
+ }
+
+ protected override object Unwrap(object value)
+ {
+ var specification = value as FieldElement;
+ if (specification != null)
+ {
+ value = specification.GetDeclaredElement();
+ }
+
+ var context = value as ContextElement;
+ if (context != null)
+ {
+ value = context.GetDeclaredElement();
+ }
+ return base.Unwrap(value);
+ }
+
+ }
+}
View
2 Source/Machine.Specifications.ReSharperRunner.6.0/Properties/AssemblyInfo.cs
@@ -23,5 +23,5 @@
[assembly: Guid("a0468d17-75ce-44fd-a346-534cacd98ecc")]
[assembly: PluginTitle("Machine.Specifications Runner for ReSharper 6.0")]
-[assembly: PluginDescription("Allows ReSharper 5.1 to run Machine.Specifications as unit tests")]
+[assembly: PluginDescription("Allows ReSharper 6.0 to run Machine.Specifications as unit tests")]
[assembly: PluginVendor("Machine")]
View
112 Source/Machine.Specifications.ReSharperRunner.6.0/Tasks/MSpecUnitTestProvider.cs
@@ -1,112 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Drawing;
-using System.Xml;
-
-using JetBrains.Application;
-using JetBrains.Metadata.Reader.API;
-using JetBrains.ProjectModel;
-using JetBrains.ReSharper.Psi;
-using JetBrains.ReSharper.Psi.Caches;
-using JetBrains.ReSharper.TaskRunnerFramework;
-using JetBrains.ReSharper.UnitTestFramework;
-
-using Machine.Specifications.ReSharperRunner.Presentation;
-using Machine.Specifications.ReSharperRunner.Properties;
-using Machine.Specifications.ReSharperRunner.Runners;
-
-namespace Machine.Specifications.ReSharperRunner
-{
- [UnitTestProvider]
- class MSpecUnitTestProvider : IUnitTestProvider
- {
- const string ProviderId = "Machine.Specifications";
- readonly UnitTestElementComparer _unitTestElementComparer = new UnitTestElementComparer();
-
- public MSpecUnitTestProvider(ISolution solution, PsiModuleManager psiModuleManager, CacheManager cacheManager)
- {
- Solution = solution;
- PsiModuleManager = psiModuleManager;
- CacheManager = cacheManager;
- Debug.Listeners.Add(new DefaultTraceListener());
- }
-
- public string ID
- {
- get { return ProviderId; }
- }
-
- public string Name
- {
- get { return ID; }
- }
-
- public IUnitTestElement DeserializeElement(XmlElement parent, IUnitTestElement parentElement)
- {
- throw new NotImplementedException();
- }
-
- public Image Icon
- {
- get { return Resources.Logo; }
- }
-
- public ISolution Solution { get; private set; }
- public PsiModuleManager PsiModuleManager { get; private set; }
- public CacheManager CacheManager { get; private set; }
-
- public void ExploreSolution(ISolution solution, UnitTestElementConsumer consumer)
- {
- }
-
- public void ExploreExternal(UnitTestElementConsumer consumer)
- {
- }
-
- public RemoteTaskRunnerInfo GetTaskRunnerInfo()
- {
- return new RemoteTaskRunnerInfo(typeof(RecursiveMSpecTaskRunner));
- }
-
- public int CompareUnitTestElements(IUnitTestElement x, IUnitTestElement y)
- {
- return _unitTestElementComparer.Compare(x, y);
- }
-
- public bool IsElementOfKind(IUnitTestElement element, UnitTestElementKind elementKind)
- {
- switch (elementKind)
- {
- case UnitTestElementKind.Test:
- return element is ContextSpecificationElement;
- case UnitTestElementKind.TestContainer:
- return element is ContextElement || element is BehaviorElement;
- }
-
- return false;
- }
-
- public bool IsElementOfKind(IDeclaredElement declaredElement, UnitTestElementKind elementKind)
- {
- switch (elementKind)
- {
- case UnitTestElementKind.Test:
- return declaredElement.IsSpecification();
- case UnitTestElementKind.TestContainer:
- return declaredElement.IsContext() || declaredElement.IsBehavior();
- }
-
- return false;
- }
-
- public bool IsSupported(IHostProvider hostProvider)
- {
- return true;
- }
-
- public void SerializeElement(XmlElement parent, IUnitTestElement element)
- {
- throw new NotImplementedException();
- }
- }
-}

0 comments on commit c10a719

Please sign in to comment.
Something went wrong with that request. Please try again.