Skip to content

Commit

Permalink
Fixing compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
kropp authored and agross committed Nov 26, 2011
1 parent dcfb24b commit 8fa7533
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 11 deletions.
Expand Up @@ -8,6 +8,9 @@
using JetBrains.ReSharper.Psi.Caches;
using JetBrains.ReSharper.TaskRunnerFramework;
using JetBrains.ReSharper.UnitTestFramework;
#if RESHARPER_61
using JetBrains.ReSharper.UnitTestFramework.Elements;
#endif

using Machine.Specifications.ReSharperRunner.Presentation;
using Machine.Specifications.ReSharperRunner.Properties;
Expand All @@ -21,6 +24,9 @@ public class MSpecUnitTestProvider : IUnitTestProvider
const string ProviderId = "Machine.Specifications";
readonly UnitTestElementComparer _unitTestElementComparer = new UnitTestElementComparer();
private UnitTestManager _unitTestManager;
#if RESHARPER_61
private IUnitTestElementManager _unitTestElementManager;
#endif

public MSpecUnitTestProvider(ISolution solution, PsiModuleManager psiModuleManager, CacheManager cacheManager)
{
Expand All @@ -32,10 +38,18 @@ public MSpecUnitTestProvider(ISolution solution, PsiModuleManager psiModuleManag

public PsiModuleManager PsiModuleManager { get; private set; }
public CacheManager CacheManager { get; private set; }

#if RESHARPER_61
public IUnitTestElementManager UnitTestManager
{
get { return _unitTestElementManager ?? (_unitTestElementManager = Solution.GetComponent<IUnitTestElementManager>()); }
}
#else
public UnitTestManager UnitTestManager
{
get { return _unitTestManager ?? (_unitTestManager = Solution.GetComponent<UnitTestManager>()); }
}
#endif

public string ID
{
Expand All @@ -62,6 +76,17 @@ public void ExploreExternal(UnitTestElementConsumer consumer)
{
}

#if !RESHARPER_61
public void SerializeElement(XmlElement parent, IUnitTestElement element)
{
var e = element as ISerializableElement;
if (e != null)
{
e.WriteToXml(parent);
parent.SetAttribute("elementType", e.GetType().Name);
}
}

public IUnitTestElement DeserializeElement(XmlElement parent, IUnitTestElement parentElement)
{
var typeName = parent.GetAttribute("elemenType");
Expand All @@ -77,8 +102,9 @@ public IUnitTestElement DeserializeElement(XmlElement parent, IUnitTestElement p

return null;
}
#endif

public RemoteTaskRunnerInfo GetTaskRunnerInfo()
public RemoteTaskRunnerInfo GetTaskRunnerInfo()
{
return new RemoteTaskRunnerInfo(typeof(RecursiveMSpecTaskRunner));
}
Expand All @@ -88,16 +114,6 @@ public int CompareUnitTestElements(IUnitTestElement x, IUnitTestElement y)
return _unitTestElementComparer.Compare(x, y);
}

public void SerializeElement(XmlElement parent, IUnitTestElement element)
{
var e = element as ISerializableElement;
if (e != null)
{
e.WriteToXml(parent);
parent.SetAttribute("elementType", e.GetType().Name);
}
}

public bool IsElementOfKind(IUnitTestElement element, UnitTestElementKind elementKind)
{
switch (elementKind)
Expand Down
Expand Up @@ -173,7 +173,11 @@ public IEnumerable<IProjectFile> GetProjectFiles()
return declaredType.GetSourceFiles().Select(x => x.ToProjectFile());
}

#if RESHARPER_61
public IList<UnitTestTask> GetTaskSequence(IList<IUnitTestElement> explicitElements)
#else
public IList<UnitTestTask> GetTaskSequence(IEnumerable<IUnitTestElement> explicitElements)
#endif
{
if (this is ContextSpecificationElement)
{
Expand Down
@@ -0,0 +1,51 @@
using System.Xml;

using JetBrains.ProjectModel;
using JetBrains.ReSharper.UnitTestFramework;

using Machine.Specifications.ReSharperRunner.Presentation;

namespace Machine.Specifications.ReSharperRunner
{
[SolutionComponent]
public class MSpecUnitTestElementSerializer : IUnitTestElementSerializer
{
readonly MSpecUnitTestProvider _provider;

public MSpecUnitTestElementSerializer(MSpecUnitTestProvider provider)
{
_provider = provider;
}

public void SerializeElement(XmlElement parent, IUnitTestElement element)
{
var e = element as ISerializableElement;
if (e != null)
{
e.WriteToXml(parent);
parent.SetAttribute("elementType", e.GetType().Name);
}
}

public IUnitTestElement DeserializeElement(XmlElement parent, IUnitTestElement parentElement)
{
var typeName = parent.GetAttribute("elemenType");

if (Equals(typeName, "ContextElement"))
return ContextElement.ReadFromXml(parent, parentElement, _provider);
if (Equals(typeName, "BehaviorElement"))
return BehaviorElement.ReadFromXml(parent, parentElement, _provider);
if (Equals(typeName, "BehaviorSpecificationElement"))
return BehaviorSpecificationElement.ReadFromXml(parent, parentElement, _provider);
if (Equals(typeName, "ContextSpecificationElement"))
return ContextSpecificationElement.ReadFromXml(parent, parentElement, _provider);

return null;
}

public IUnitTestProvider Provider
{
get { return _provider; }
}
}
}
Expand Up @@ -219,6 +219,7 @@
<Compile Include="..\Machine.Specifications.ReSharperRunner.6.0\Presentation\Presenter.cs">
<Link>Presentation\Presenter.cs</Link>
</Compile>
<Compile Include="MSpecUnitTestElementSerializer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
Expand Down

0 comments on commit 8fa7533

Please sign in to comment.