Skip to content

Commit

Permalink
Preparing ReSharper runner to fix #17
Browse files Browse the repository at this point in the history
  • Loading branch information
agross committed Jan 25, 2013
1 parent ac539c4 commit 21d0534
Show file tree
Hide file tree
Showing 19 changed files with 308 additions and 84 deletions.
@@ -1,5 +1,4 @@
using JetBrains.ReSharper.TaskRunnerFramework;
using JetBrains.ReSharper.UnitTestExplorer;
using JetBrains.ReSharper.UnitTestFramework;

using Machine.Specifications.ReSharperRunner.Presentation;
Expand All @@ -22,6 +21,12 @@ public UnitTestTask CreateAssemblyLoadTask(ContextElement context)
new AssemblyLoadTask(context.AssemblyLocation));
}

public UnitTestTask CreateRunAssemblyTask(ContextElement context)
{
return new UnitTestTask(null,
new RunAssemblyTask(_providerId, context.AssemblyLocation));
}

public UnitTestTask CreateContextTask(ContextElement context, bool isExplicit)
{
return new UnitTestTask(context,
Expand Down
Expand Up @@ -151,6 +151,7 @@
<Compile Include="PsiExtensions.cs" />
<Compile Include="Runners\ExceptionResultConverter.cs" />
<Compile Include="Runners\Notifications\BehaviorSpecificationRemoteTaskNotification.cs" />
<Compile Include="Runners\Notifications\ContextRemoteTaskNotification.cs" />
<Compile Include="Runners\Notifications\ContextSpecificationRemoteTaskNotification.cs" />
<Compile Include="Runners\Notifications\RemoteTaskNotification.cs" />
<Compile Include="Runners\Notifications\RemoteTaskNotificationFactory.cs" />
Expand All @@ -162,6 +163,7 @@
<Compile Include="Tasks\BehaviorTask.cs" />
<Compile Include="Tasks\ContextSpecificationTask.cs" />
<Compile Include="Tasks\ContextTask.cs" />
<Compile Include="Tasks\RunAssemblyContextsTask.cs" />
<Compile Include="Tasks\Task.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
Expand Up @@ -197,6 +197,7 @@ public IList<UnitTestTask> GetTaskSequence(IList<IUnitTestElement> explicitEleme
return new List<UnitTestTask>
{
_taskFactory.CreateAssemblyLoadTask(context),
_taskFactory.CreateRunAssemblyTask(context),
_taskFactory.CreateContextTask(context, explicitElements.Contains(context)),
_taskFactory.CreateContextSpecificationTask(context,
contextSpecification,
Expand All @@ -212,6 +213,7 @@ public IList<UnitTestTask> GetTaskSequence(IList<IUnitTestElement> explicitEleme
return new List<UnitTestTask>
{
_taskFactory.CreateAssemblyLoadTask(context),
_taskFactory.CreateRunAssemblyTask(context),
_taskFactory.CreateContextTask(context, explicitElements.Contains(context)),
_taskFactory.CreateBehaviorTask(context, behavior, explicitElements.Contains(behavior))
};
Expand All @@ -226,6 +228,7 @@ public IList<UnitTestTask> GetTaskSequence(IList<IUnitTestElement> explicitEleme
return new List<UnitTestTask>
{
_taskFactory.CreateAssemblyLoadTask(context),
_taskFactory.CreateRunAssemblyTask(context),
_taskFactory.CreateContextTask(context, explicitElements.Contains(context)),
_taskFactory.CreateBehaviorTask(context, behavior, explicitElements.Contains(behavior)),
_taskFactory.CreateBehaviorSpecificationTask(context,
Expand Down
@@ -1,12 +1,15 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;

using JetBrains.ReSharper.TaskRunnerFramework;

using Machine.Specifications.ReSharperRunner.Tasks;
using Machine.Specifications.Runner;

namespace Machine.Specifications.ReSharperRunner.Runners.Notifications
{
internal class BehaviorSpecificationRemoteTaskNotification : RemoteTaskNotification
class BehaviorSpecificationRemoteTaskNotification : RemoteTaskNotification
{
readonly TaskExecutionNode _node;

Expand All @@ -18,22 +21,40 @@ public BehaviorSpecificationRemoteTaskNotification(TaskExecutionNode node)
_task = (BehaviorSpecificationTask) node.RemoteTask;
}

protected override string ContainingType
string ContainingType
{
get { return _task.BehaviorTypeName; }
}

protected override string FieldName
string FieldName
{
get { return _task.SpecificationFieldName; }
}

public override IEnumerable<RemoteTask> RemoteTasks
{
get
get { yield return _node.RemoteTask; }
}

public override bool Matches(object infoFromRunner)
{
var specification = infoFromRunner as SpecificationInfo;

if (specification == null)
{
yield return _node.RemoteTask;
return false;
}

return ContainingType == specification.ContainingType &&
FieldName == specification.FieldName;
}

public override string ToString()
{
return String.Format("Behavior specification {0}.{1} with {2} remote tasks",
ContainingType,
FieldName,
RemoteTasks.Count());
}
}
}
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;

using JetBrains.ReSharper.TaskRunnerFramework;

using Machine.Specifications.ReSharperRunner.Tasks;
using Machine.Specifications.Runner;

namespace Machine.Specifications.ReSharperRunner.Runners.Notifications
{
class ContextRemoteTaskNotification : RemoteTaskNotification
{
readonly TaskExecutionNode _node;
readonly ContextTask _task;

public ContextRemoteTaskNotification(TaskExecutionNode node)
{
_node = node;
_task = (ContextTask) node.RemoteTask;
}

string ContainingType
{
get { return _task.ContextTypeName; }
}

public override IEnumerable<RemoteTask> RemoteTasks
{
get { yield return _node.RemoteTask; }
}

public override bool Matches(object infoFromRunner)
{
var context = infoFromRunner as ContextInfo;

if (context == null)
{
return false;
}

return ContainingType == context.TypeName;
}

public override string ToString()
{
return String.Format("Context {0} with {1} remote tasks",
ContainingType,
RemoteTasks.Count());
}
}
}
@@ -1,12 +1,15 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;

using JetBrains.ReSharper.TaskRunnerFramework;

using Machine.Specifications.ReSharperRunner.Tasks;
using Machine.Specifications.Runner;

namespace Machine.Specifications.ReSharperRunner.Runners.Notifications
{
internal class ContextSpecificationRemoteTaskNotification : RemoteTaskNotification
class ContextSpecificationRemoteTaskNotification : RemoteTaskNotification
{
readonly TaskExecutionNode _node;
readonly ContextSpecificationTask _task;
Expand All @@ -17,12 +20,12 @@ public ContextSpecificationRemoteTaskNotification(TaskExecutionNode node)
_task = (ContextSpecificationTask) node.RemoteTask;
}

protected override string ContainingType
string ContainingType
{
get { return _task.ContextTypeName; }
}

protected override string FieldName
string FieldName
{
get { return _task.SpecificationFieldName; }
}
Expand All @@ -31,5 +34,26 @@ public override IEnumerable<RemoteTask> RemoteTasks
{
get { yield return _node.RemoteTask; }
}

public override bool Matches(object infoFromRunner)
{
var specification = infoFromRunner as SpecificationInfo;

if (specification == null)
{
return false;
}

return ContainingType == specification.ContainingType &&
FieldName == specification.FieldName;
}

public override string ToString()
{
return String.Format("Context specification {0}.{1} with {2} remote tasks",
ContainingType,
FieldName,
RemoteTasks.Count());
}
}
}
Expand Up @@ -2,31 +2,11 @@

using JetBrains.ReSharper.TaskRunnerFramework;

using Machine.Specifications.Runner;

namespace Machine.Specifications.ReSharperRunner.Runners.Notifications
{
internal abstract class RemoteTaskNotification
abstract class RemoteTaskNotification
{
protected abstract string ContainingType
{
get;
}

protected abstract string FieldName
{
get;
}

public abstract IEnumerable<RemoteTask> RemoteTasks
{
get;
}

public virtual bool Matches(SpecificationInfo specification)
{
return ContainingType == new NormalizedTypeName(specification.ContainingType) &&
FieldName == specification.FieldName;
}
public abstract IEnumerable<RemoteTask> RemoteTasks { get; }
public abstract bool Matches(object infoFromRunner);
}
}
Expand Up @@ -4,12 +4,17 @@

namespace Machine.Specifications.ReSharperRunner.Runners.Notifications
{
internal class RemoteTaskNotificationFactory
class RemoteTaskNotificationFactory
{
public RemoteTaskNotification CreateTaskNotification(TaskExecutionNode node)
{
var remoteTask = node.RemoteTask;

if (remoteTask is ContextTask)
{
return new ContextRemoteTaskNotification(node);
}

if (remoteTask is ContextSpecificationTask)
{
return new ContextSpecificationRemoteTaskNotification(node);
Expand Down
Expand Up @@ -6,19 +6,14 @@ namespace Machine.Specifications.ReSharperRunner.Runners.Notifications
{
internal class SilentRemoteTaskNotification : RemoteTaskNotification
{
protected override string ContainingType
{
get { return null; }
}

protected override string FieldName
public override IEnumerable<RemoteTask> RemoteTasks
{
get { return null; }
get { yield break; }
}

public override IEnumerable<RemoteTask> RemoteTasks
public override bool Matches(object infoFromRunner)
{
get { yield break; }
return false;
}
}
}

0 comments on commit 21d0534

Please sign in to comment.