Skip to content

Commit a31f686

Browse files
committed
Merge pull request #81 from MehdiK/inline-assertions
Awesome work, Mehdi.
2 parents 5a36a79 + 0404fc1 commit a31f686

19 files changed

Lines changed: 242 additions & 143 deletions

TestStack.BDDfy.Tests/FluentScanner/BDDfyUsingFluentApi.cs renamed to TestStack.BDDfy.Tests/Scanner/FluentScanner/BDDfyUsingFluentApi.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using System.Reflection;
45
using NUnit.Framework;
5-
using System.Linq;
66
using TestStack.BDDfy.Configuration;
77

8-
namespace TestStack.BDDfy.Tests.FluentScanner
8+
namespace TestStack.BDDfy.Tests.Scanner.FluentScanner
99
{
1010
public enum SomeEnumForTesting
1111
{
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using NUnit.Framework;
2+
3+
namespace TestStack.BDDfy.Tests.Scanner.FluentScanner
4+
{
5+
[TestFixture]
6+
public class InlineAssertions
7+
{
8+
private int _x, _y, _z;
9+
10+
[Test]
11+
public void CanUseInlineAssertions()
12+
{
13+
this.Given(() => { _x = 0; _y = 2; }, "Given x equals 0")
14+
.When(() => { _z = _x*_y; }, "When x and y are multiplied")
15+
.Then(() => Assert.That(_z, Is.EqualTo(0)), "Then the result is 0")
16+
.BDDfy();
17+
}
18+
19+
[Test]
20+
public void CanUseTitleOnlySteps()
21+
{
22+
this.Given("Given x equals 0")
23+
.And("and y equals 0")
24+
.When("When x and y are multiplied")
25+
.And("and set to z")
26+
.Then("Then z equals 0")
27+
.And("and we're all cool")
28+
.BDDfy();
29+
}
30+
31+
[Test]
32+
public void CanMixThemAllIn()
33+
{
34+
this.Given(() => { _x = 0; _y = 2; }, "Given x equals 0")
35+
.And("and y equals 0")
36+
.When(_ => WhenXAndYAreMultiplied())
37+
.And("and set to z")
38+
.Then(() => Assert.That(_z, Is.EqualTo(0)), "Then the result is 0")
39+
.And("and we're all cool")
40+
.BDDfy();
41+
42+
}
43+
44+
void WhenXAndYAreMultiplied()
45+
{
46+
_z = _x*_y;
47+
}
48+
}
49+
}

TestStack.BDDfy.Tests/FluentScanner/ScenarioToBeScannedUsingFluentScanner.cs renamed to TestStack.BDDfy.Tests/Scanner/FluentScanner/ScenarioToBeScannedUsingFluentScanner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Globalization;
34
using System.Linq;
4-
using System.Collections.Generic;
55

6-
namespace TestStack.BDDfy.Tests.FluentScanner
6+
namespace TestStack.BDDfy.Tests.Scanner.FluentScanner
77
{
88
[Story]
99
class ScenarioToBeScannedUsingFluentScanner

TestStack.BDDfy.Tests/FluentScanner/WhenStepsAreScannedUsingFluentScanner.cs renamed to TestStack.BDDfy.Tests/Scanner/FluentScanner/WhenStepsAreScannedUsingFluentScanner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System.Collections.Generic;
2-
using NUnit.Framework;
32
using System.Linq;
3+
using NUnit.Framework;
44

5-
namespace TestStack.BDDfy.Tests.FluentScanner
5+
namespace TestStack.BDDfy.Tests.Scanner.FluentScanner
66
{
77
[TestFixture]
88
public class WhenStepsAreScannedUsingFluentScanner

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
<Compile Include="Reporters\Html\HtmlReportBuilderTests.cs" />
7878
<Compile Include="Reporters\Html\HtmlReporterTests.cs" />
7979
<Compile Include="Reporters\Html\TestableHtmlReporter.cs" />
80+
<Compile Include="Scanner\FluentScanner\InlineAssertions.cs" />
8081
<Compile Include="Scanner\WhenStepScannerFactoryAsyncMethods.cs" />
8182
<Compile Include="Configuration\CustomProcessor.cs" />
8283
<Compile Include="Configuration\BatchProcessorsTests.cs" />
@@ -86,11 +87,11 @@
8687
<Compile Include="Exceptions\ThrowingMethods.cs" />
8788
<Compile Include="Exceptions\WhenAnInconclusiveTestIsRun.cs" />
8889
<Compile Include="Exceptions\ExceptionThrowingTest.cs" />
89-
<Compile Include="FluentScanner\BDDfyUsingFluentApi.cs" />
90-
<Compile Include="FluentScanner\ScenarioToBeScannedUsingFluentScanner.cs">
90+
<Compile Include="Scanner\FluentScanner\BDDfyUsingFluentApi.cs" />
91+
<Compile Include="Scanner\FluentScanner\ScenarioToBeScannedUsingFluentScanner.cs">
9192
<SubType>Code</SubType>
9293
</Compile>
93-
<Compile Include="FluentScanner\WhenStepsAreScannedUsingFluentScanner.cs">
94+
<Compile Include="Scanner\FluentScanner\WhenStepsAreScannedUsingFluentScanner.cs">
9495
<SubType>Code</SubType>
9596
</Compile>
9697
<Compile Include="HumanizerTests.cs" />

0 commit comments

Comments
 (0)