Skip to content

Commit 4bc96b2

Browse files
author
Johan Bergens
committed
Added test for showing problem with examples ending in numbers.
1 parent 603ed9a commit 4bc96b2

4 files changed

Lines changed: 70 additions & 0 deletions
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+

2+
Scenario: Fluent can be used with examples
3+
Given method taking <example int a>
4+
When empty method
5+
Then all is good
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+

2+
Scenario: Fluent can be used with examples ending in a number
3+
Given method taking <example int 1>
4+
When empty method
5+
Then all is good
6+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Runtime.CompilerServices;
3+
using ApprovalTests;
4+
using Shouldly;
5+
using TestStack.BDDfy.Reporters;
6+
using Xunit;
7+
8+
namespace TestStack.BDDfy.Tests.Scanner.Examples
9+
{
10+
public class FluentWithExamplesAtEnd
11+
{
12+
[Fact]
13+
public void FluentCanBeUsedWithExamples()
14+
{
15+
var story = this
16+
.Given(_ => MethodTaking__ExampleIntA__(1), false)
17+
.When(_ => WhenEmptyMethod())
18+
.Then(_ => ThenAllIsGood())
19+
.BDDfy();
20+
21+
var textReporter = new TextReporter();
22+
textReporter.Process(story);
23+
Approvals.Verify(textReporter.ToString());
24+
}
25+
26+
// This test crashes BDDfy or causes an infinite loop
27+
[Fact]
28+
public void FluentCanBeUsedWithExamplesEndingInANumber() {
29+
var story = this
30+
.Given(_ => MethodTaking__ExampleInt1__(1), false)
31+
.When(_ => WhenEmptyMethod())
32+
.Then(_ => ThenAllIsGood())
33+
.BDDfy();
34+
35+
var textReporter = new TextReporter();
36+
textReporter.Process(story);
37+
Approvals.Verify(textReporter.ToString());
38+
}
39+
40+
private void ThenAllIsGood()
41+
{
42+
}
43+
44+
private void WhenEmptyMethod()
45+
{
46+
}
47+
48+
private void MethodTaking__ExampleInt1__(int exampleInt)
49+
{
50+
exampleInt.ShouldBeInRange(1, 2);
51+
}
52+
53+
private void MethodTaking__ExampleIntA__(int exampleInt) {
54+
exampleInt.ShouldBeInRange(1, 2);
55+
}
56+
}
57+
}

src/TestStack.BDDfy.Tests/TestStack.BDDfy.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
<Compile Include="Reporters\Html\TestableHtmlReporter.cs" />
8888
<Compile Include="Reporters\ReportApprover.cs" />
8989
<Compile Include="Scanner\Examples\ExampleActionTests.cs" />
90+
<Compile Include="Scanner\Examples\FluentWithExamplesAtEnd.cs" />
9091
<Compile Include="Scanner\FluentScanner\ComplexStepsTests.cs" />
9192
<Compile Include="Scanner\FluentScanner\DoesNotConflictWithnSubstitute.cs" />
9293
<Compile Include="Scanner\Examples\FluentWithExamples.cs" />

0 commit comments

Comments
 (0)