Skip to content

Commit 2c4b919

Browse files
author
Jake Ginnivan
committed
Allow step title placeholders when matching variable is passed in as well as the parameter name matching
1 parent efaaf4b commit 2c4b919

5 files changed

Lines changed: 13 additions & 10 deletions

File tree

TestStack.BDDfy.Tests/Processors/TestRunnerTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ public class TestRunnerTests
1414
[Test]
1515
public void InitialisesScenarioWithExampleBeforeRunning()
1616
{
17-
const int ExpectedValue = 1;
17+
const int expectedValue = 1;
1818
int actualValue = 0;
1919
var exampleTable = new ExampleTable("ExampleValue")
2020
{
21-
ExpectedValue
21+
expectedValue
2222
}.Single();
2323

2424
var sut = new TestRunner();
@@ -31,7 +31,7 @@ public void InitialisesScenarioWithExampleBeforeRunning()
3131

3232
sut.Process(story);
3333

34-
Assert.AreEqual(ExpectedValue, actualValue);
34+
Assert.AreEqual(expectedValue, actualValue);
3535
}
3636
}
3737
}

TestStack.BDDfy.Tests/Scanner/FluentScanner/FluentWithExamples.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public void FluentCanBeUsedWithExamples()
3232
Approvals.Verify(textReporter.ToString());
3333
}
3434

35-
private void GivenIntWithValue(int inlineVariable)
35+
private void GivenIntWithValue(int differentName)
3636
{
37-
inlineVariable.ShouldBeOneOf(1, 2);
37+
differentName.ShouldBeOneOf(1, 2);
3838
}
3939

4040
[Test]

TestStack.BDDfy/Processors/ScenarioExecutor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Linq;
33
using System.Reflection;
4-
using System.Web.Compilation;
54

65
namespace TestStack.BDDfy.Processors
76
{

TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleTable.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ static object[] GetValues(string row)
8686

8787
public static bool HeaderMatches(string header, string name)
8888
{
89+
if (name == null)
90+
return false;
91+
8992
return Sanitise(name).Equals(Sanitise(header), StringComparison.InvariantCultureIgnoreCase);
9093
}
9194

TestStack.BDDfy/Scanners/StepScanners/Fluent/FluentScanner.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,19 @@ private StepTitle CreateTitle(string stepTextTemplate, bool includeInputsInStepT
147147
{
148148
var parameters = methodInfo.GetParameters();
149149
var stringFlatInputs =
150-
flatInputArray
150+
inputArguments
151151
.Select((a, i) => new { ParameterName = parameters[i].Name, Value = a })
152152
.Select(i =>
153153
{
154154
if (_testContext.Examples != null)
155155
{
156-
157-
var matchingHeader = _testContext.Examples.Headers.SingleOrDefault(header => ExampleTable.HeaderMatches(header, i.ParameterName));
156+
var matchingHeader = _testContext.Examples.Headers
157+
.SingleOrDefault(header => ExampleTable.HeaderMatches(header, i.ParameterName) ||
158+
ExampleTable.HeaderMatches(header, i.Value.Name));
158159
if (matchingHeader != null)
159160
return string.Format("<{0}>", matchingHeader);
160161
}
161-
return i.Value.ToString();
162+
return i.Value.Value.FlattenArray();
162163
})
163164
.ToArray();
164165
stepTitle = stepTitle + " " + string.Join(", ", stringFlatInputs);

0 commit comments

Comments
 (0)