More Fluent Interfaces for NUnit.Behave
I have been enhancing the overall structure of NUnit.Behave to evolve to a more fluent interface. The following is a working example of what I have come up with.
Story("Account Holder withdraws cash")
.As_a("savings account holder")
.I_Want("to transfer money from my savings account")
.So_That("I can get cash easily from an ATM")
.Scenario("savings account is overdrawn")
.Given("my savings account balance is", -20)
.And("my cash account balance is", 10)
.When("I transfer to cash account", 20)
.Then("my savings account balance should be", -20)
.And("my cash account balance should be", 10);
<p>
In the test runner the following output appears.
</p>
<p>
<font face="Courier New">Story: Account Holder withdraws cash<br />Narrative: As a savings account holder <br /> I want to transfer money from my savings account <br /> so that I can get cash easily from an ATM. </font>
</p>
<p>
<font face="Courier New"> Scenario: savings account is overdrawn<br /> Given my savings account balance is: -20 !PENDING Delegate IMPLEMENTATION!<br /> And my cash account balance is: 10 !PENDING Delegate IMPLEMENTATION!<br /> When I transfer to cash account: 20 !PENDING Delegate IMPLEMENTATION!<br /> Then my savings account balance should be: -20 !PENDING Delegate IMPLEMENTATION!<br /> And my cash account balance should be: 10 !PENDING Delegate IMPLEMENTATION!</font>
</p>
<p>
Don’t worry I am working on “!PENDING” but I just needed something as placeholder for the time being.
</p>
<p>
I love this fluent interface approach though. It really makes the code much more maintainable.
</p>
