Skip to content

Commit 017cb85

Browse files
committed
Allow ExampleActions
1 parent a0fb16f commit 017cb85

File tree

12 files changed

+862
-19
lines changed

12 files changed

+862
-19
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+

2+
Scenario: Can use actions in examples
3+
Given some setup
4+
When <Action to perform>
5+
Then should be <Value should be>
6+
7+
Examples:
8+
| Action to perform | Value should be |
9+
| Do something | 42 |
10+
| Do something else | 7 |
11+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using ApprovalTests;
2+
using NUnit.Framework;
3+
using Shouldly;
4+
using TestStack.BDDfy.Reporters;
5+
6+
namespace TestStack.BDDfy.Tests.Scanner.Examples
7+
{
8+
[TestFixture]
9+
public class ExampleActionTests
10+
{
11+
private int value;
12+
13+
[Test]
14+
public void CanUseActionsInExamples()
15+
{
16+
ExampleAction actionToPerform = null;
17+
int valueShouldBe = 0;
18+
var story = this.Given(_ => SomeSetup())
19+
.When(() => actionToPerform)
20+
.Then(_ => ShouldBe(valueShouldBe))
21+
.WithExamples(new ExampleTable("Action to perform", "Value should be")
22+
{
23+
{ new ExampleAction("Do something", () => { value = 42; }), 42 },
24+
{ new ExampleAction("Do something else", () => { value = 7; }), 7 }
25+
})
26+
.BDDfy();
27+
28+
29+
var textReporter = new TextReporter();
30+
textReporter.Process(story);
31+
Approvals.Verify(textReporter.ToString());
32+
}
33+
34+
private void ShouldBe(int i)
35+
{
36+
value.ShouldBe(i);
37+
}
38+
39+
private void SomeSetup()
40+
{
41+
42+
}
43+
}
44+
}

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

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

TestStack.BDDfy.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=TestStack_002EBDDfy_002EAnnotations/@EntryIndexedValue">True</s:Boolean>
23
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CheckNamespace/@EntryIndexedValue">DO_NOT_SHOW</s:String></wpf:ResourceDictionary>

0 commit comments

Comments
 (0)