Permalink
Browse files

Fixing behavior results being reported more than once to ReSharper, c…

…loses #135
  • Loading branch information...
1 parent be18fef commit c6f89b018dd1a40de975e69ac6b81a0f2977ff1b @agross agross committed Mar 4, 2013
View
16 ....ReSharperRunner.6.1/Runners/Notifications/BehaviorSpecificationRemoteTaskNotification.cs
@@ -21,6 +21,11 @@ public BehaviorSpecificationRemoteTaskNotification(TaskExecutionNode node)
_task = (BehaviorSpecificationTask) node.RemoteTask;
}
+ string ContextTypeName
+ {
+ get { return _task.ContextTypeName; }
+ }
+
string ContainingType
{
get { return _task.BehaviorTypeName; }
@@ -36,16 +41,21 @@ public override IEnumerable<RemoteTask> RemoteTasks
get { yield return _node.RemoteTask; }
}
- public override bool Matches(object infoFromRunner)
+ public override bool Matches(object infoFromRunner, ContextInfo maybeContext)
{
- var specification = infoFromRunner as SpecificationInfo;
+ if (maybeContext == null)
+ {
+ return false;
+ }
+ var specification = infoFromRunner as SpecificationInfo;
if (specification == null)
{
return false;
}
- return ContainingType == new NormalizedTypeName(specification.ContainingType) &&
+ return ContextTypeName == maybeContext.TypeName &&
+ ContainingType == new NormalizedTypeName(specification.ContainingType) &&
FieldName == specification.FieldName;
}
View
2 ...Specifications.ReSharperRunner.6.1/Runners/Notifications/ContextRemoteTaskNotification.cs
@@ -30,7 +30,7 @@ public override IEnumerable<RemoteTask> RemoteTasks
get { yield return _node.RemoteTask; }
}
- public override bool Matches(object infoFromRunner)
+ public override bool Matches(object infoFromRunner, ContextInfo maybeContext)
{
var context = infoFromRunner as ContextInfo;
View
2 ...s.ReSharperRunner.6.1/Runners/Notifications/ContextSpecificationRemoteTaskNotification.cs
@@ -35,7 +35,7 @@ public override IEnumerable<RemoteTask> RemoteTasks
get { yield return _node.RemoteTask; }
}
- public override bool Matches(object infoFromRunner)
+ public override bool Matches(object infoFromRunner, ContextInfo maybeContext)
{
var specification = infoFromRunner as SpecificationInfo;
View
4 ...achine.Specifications.ReSharperRunner.6.1/Runners/Notifications/RemoteTaskNotification.cs
@@ -2,11 +2,13 @@
using JetBrains.ReSharper.TaskRunnerFramework;
+using Machine.Specifications.Runner;
+
namespace Machine.Specifications.ReSharperRunner.Runners.Notifications
{
abstract class RemoteTaskNotification
{
public abstract IEnumerable<RemoteTask> RemoteTasks { get; }
- public abstract bool Matches(object infoFromRunner);
+ public abstract bool Matches(object infoFromRunner, ContextInfo maybeContext);
}
}
View
4 ....Specifications.ReSharperRunner.6.1/Runners/Notifications/SilentRemoteTaskNotification.cs
@@ -2,6 +2,8 @@
using JetBrains.ReSharper.TaskRunnerFramework;
+using Machine.Specifications.Runner;
+
namespace Machine.Specifications.ReSharperRunner.Runners.Notifications
{
internal class SilentRemoteTaskNotification : RemoteTaskNotification
@@ -11,7 +13,7 @@ public override IEnumerable<RemoteTask> RemoteTasks
get { yield break; }
}
- public override bool Matches(object infoFromRunner)
+ public override bool Matches(object infoFromRunner, ContextInfo maybeContext)
{
return false;
}
View
15 Source/Machine.Specifications.ReSharperRunner.6.1/Runners/PerAssemblyRunListener.cs
@@ -18,6 +18,7 @@ class PerAssemblyRunListener : ISpecificationRunListener
int _specifications;
int _successes;
int _errors;
+ ContextInfo _currentContext;
public PerAssemblyRunListener(IRemoteTaskServer server, RunAssemblyTask runAssemblyTask)
{
@@ -48,7 +49,9 @@ public void OnContextStart(ContextInfo context)
_errors = 0;
_successes = 0;
- var notify = CreateTaskNotificationFor(context);
+ // TODO: This sucks, but there's no better way unless we make behaviors first-class citizens.
+ _currentContext = context;
+ var notify = CreateTaskNotificationFor(context, context);
notify(task => _server.TaskStarting(task));
}
@@ -64,21 +67,21 @@ public void OnContextEnd(ContextInfo context)
result = TaskResult.Error;
}
- var notify = CreateTaskNotificationFor(context);
+ var notify = CreateTaskNotificationFor(context, _currentContext);
notify(task => _server.TaskFinished(task, null, result));
}
public void OnSpecificationStart(SpecificationInfo specification)
{
_specifications += 1;
- var notify = CreateTaskNotificationFor(specification);
+ var notify = CreateTaskNotificationFor(specification, _currentContext);
notify(task => _server.TaskStarting(task));
}
public void OnSpecificationEnd(SpecificationInfo specification, Result result)
{
- var notify = CreateTaskNotificationFor(specification);
+ var notify = CreateTaskNotificationFor(specification, _currentContext);
notify(task => _server.TaskProgress(task, null));
@@ -134,15 +137,15 @@ internal void RegisterTaskNotification(RemoteTaskNotification notification)
_taskNotifications.Add(notification);
}
- Action<Action<RemoteTask>> CreateTaskNotificationFor(object infoFromRunner)
+ Action<Action<RemoteTask>> CreateTaskNotificationFor(object infoFromRunner, ContextInfo maybeContext)
{
return actionToBePerformedForEachTask =>
{
bool invoked = false;
foreach (var notification in _taskNotifications)
{
- if (notification.Matches(infoFromRunner))
+ if (notification.Matches(infoFromRunner, maybeContext))
{
Debug.WriteLine(String.Format("Invoking notification for {0}", notification.ToString()));
invoked = true;
View
2 Source/Machine.Specifications.ReSharperRunner.6.1/Tasks/BehaviorSpecificationTask.cs
@@ -28,7 +28,7 @@ public BehaviorSpecificationTask(XmlElement element) : base(element)
SpecificationFieldNameOnContext = specificationFieldNameOnContext;
}
- string ContextTypeName { get; set; }
+ public string ContextTypeName { get; set; }
public string BehaviorTypeName { get; private set; }

0 comments on commit c6f89b0

Please sign in to comment.