Skip to content

Commit b96c37e

Browse files
author
Jake Ginnivan
committed
Introduced StepActionFactory to give a nice spot to introduce async support
1 parent f8fcc7c commit b96c37e

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

TestStack.BDDfy/Processors/TestRunner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void Process(Story story)
1818
if (scenario.ExecuteStep(executionStep) == StepExecutionResult.Passed)
1919
continue;
2020

21-
if(!executionStep.Asserts)
21+
if(!executionStep.Asserts)
2222
break;
2323
}
2424
}

TestStack.BDDfy/Scanners/StepScanners/ExecutableAttribute/ExecutableAttributeStepScanner.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections.Generic;
32
using System.Linq;
43
using System.Reflection;
@@ -42,7 +41,7 @@ public IEnumerable<ExecutionStep> Scan(object testObject, MethodInfo candidateMe
4241
if (runStepWithArgsAttributes.Length == 0)
4342
{
4443
yield return
45-
new ExecutionStep(GetStepAction(candidateMethod), stepTitle, stepAsserts, executableAttribute.ExecutionOrder, true)
44+
new ExecutionStep(StepActionFactory.GetStepAction(candidateMethod, new object[0]), stepTitle, stepAsserts, executableAttribute.ExecutionOrder, true)
4645
{
4746
ExecutionSubOrder = executableAttribute.Order
4847
};
@@ -61,19 +60,14 @@ public IEnumerable<ExecutionStep> Scan(object testObject, MethodInfo candidateMe
6160
methodName = string.Format(executableAttribute.StepTitle, flatInput);
6261

6362
yield return
64-
new ExecutionStep(GetStepAction(candidateMethod, inputArguments), methodName, stepAsserts,
63+
new ExecutionStep(StepActionFactory.GetStepAction(candidateMethod, inputArguments), methodName, stepAsserts,
6564
executableAttribute.ExecutionOrder, true)
6665
{
6766
ExecutionSubOrder = executableAttribute.Order
6867
};
6968
}
7069
}
7170

72-
static Action<object> GetStepAction(MethodInfo methodinfo, object[] inputArguments = null)
73-
{
74-
return o => methodinfo.Invoke(o, inputArguments);
75-
}
76-
7771
private static bool IsAssertingByAttribute(MethodInfo method)
7872
{
7973
var attribute = GetExecutableAttribute(method);

TestStack.BDDfy/Scanners/StepScanners/MethodName/MethodNameStepScanner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static Action<object> GetStepAction(MethodInfo method, object[] inputs, bool ret
135135
return o => InvokeIEnumerableMethod(method, o, inputs).Count();
136136
}
137137

138-
return o => method.Invoke(o, inputs);
138+
return StepActionFactory.GetStepAction(method, inputs);
139139
}
140140

141141
private static IEnumerable<string> InvokeIEnumerableMethod(MethodInfo method, object testObject, object[] inputs)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Reflection;
3+
4+
namespace TestStack.BDDfy.Scanners.StepScanners
5+
{
6+
public class StepActionFactory
7+
{
8+
public static Action<object> GetStepAction(MethodInfo method, object[] inputs)
9+
{
10+
return o => method.Invoke(o, inputs);
11+
}
12+
}
13+
}

TestStack.BDDfy/TestStack.BDDfy.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
<Compile Include="Scanners\StepScanners\MethodName\DefaultMethodNameStepScanner.cs" />
147147
<Compile Include="Scanners\StepScanners\MethodName\MethodNameMatcher.cs" />
148148
<Compile Include="Scanners\StepScanners\MethodName\MethodNameStepScanner.cs" />
149+
<Compile Include="Scanners\StepScanners\StepActionFactory.cs" />
149150
<Compile Include="Scanners\StepScanners\StepScannerExtensions.cs" />
150151
<Compile Include="Scanners\StepScanners\StepTitleException.cs" />
151152
<Compile Include="Scanners\StoryAttributeMetaDataScanner.cs" />

0 commit comments

Comments
 (0)