Navigation Menu

Skip to content

Commit

Permalink
Allow ExampleActions
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeGinnivan committed Oct 3, 2014
1 parent a0fb16f commit 017cb85
Show file tree
Hide file tree
Showing 12 changed files with 862 additions and 19 deletions.
@@ -0,0 +1,11 @@

Scenario: Can use actions in examples
Given some setup
When <Action to perform>
Then should be <Value should be>

Examples:
| Action to perform | Value should be |
| Do something | 42 |
| Do something else | 7 |

44 changes: 44 additions & 0 deletions TestStack.BDDfy.Tests/Scanner/Examples/ExampleActionTests.cs
@@ -0,0 +1,44 @@
using ApprovalTests;
using NUnit.Framework;
using Shouldly;
using TestStack.BDDfy.Reporters;

namespace TestStack.BDDfy.Tests.Scanner.Examples
{
[TestFixture]
public class ExampleActionTests
{
private int value;

[Test]
public void CanUseActionsInExamples()
{
ExampleAction actionToPerform = null;
int valueShouldBe = 0;
var story = this.Given(_ => SomeSetup())
.When(() => actionToPerform)
.Then(_ => ShouldBe(valueShouldBe))
.WithExamples(new ExampleTable("Action to perform", "Value should be")
{
{ new ExampleAction("Do something", () => { value = 42; }), 42 },
{ new ExampleAction("Do something else", () => { value = 7; }), 7 }
})
.BDDfy();


var textReporter = new TextReporter();
textReporter.Process(story);
Approvals.Verify(textReporter.ToString());
}

private void ShouldBe(int i)
{
value.ShouldBe(i);
}

private void SomeSetup()
{

}
}
}
1 change: 1 addition & 0 deletions TestStack.BDDfy.Tests/TestStack.BDDfy.Tests.csproj
Expand Up @@ -88,6 +88,7 @@
<Compile Include="Reporters\Html\TemporaryCulture.cs" />
<Compile Include="Reporters\Html\TestableHtmlReporter.cs" />
<Compile Include="Reporters\ReportApprover.cs" />
<Compile Include="Scanner\Examples\ExampleActionTests.cs" />
<Compile Include="Scanner\FluentScanner\ComplexStepsTests.cs" />
<Compile Include="Scanner\FluentScanner\DoesNotConflictWithnSubstitute.cs" />
<Compile Include="Scanner\Examples\FluentWithExamples.cs" />
Expand Down
1 change: 1 addition & 0 deletions TestStack.BDDfy.sln.DotSettings
@@ -1,2 +1,3 @@
<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">
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=TestStack_002EBDDfy_002EAnnotations/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CheckNamespace/@EntryIndexedValue">DO_NOT_SHOW</s:String></wpf:ResourceDictionary>

0 comments on commit 017cb85

Please sign in to comment.