using System;
using NBehave.Narrator.Framework;
using NBehave.Spec.Framework;
namespace TestAssembly
{
[Theme("Account transfers and deposits")]
public class AccountSpecs
{
[Story]
public void Transfer_to_cash_account()
{
Account savings = null;
Account cash = null;
Story transferStory = new Story("Transfer to cash account");
transferStory
.AsA("savings account holder")
.IWant("to transfer money from my savings account")
.SoThat("I can get cash easily from an ATM");
transferStory
.WithScenario("Savings account is in credit")
.Given("my savings account balance is", 100,
delegate(int accountBalance) { savings = new Account(accountBalance); })
.And("my cash account balance is", 10,
delegate(int accountBalance) { cash = new Account(accountBalance); })
.When("I transfer to cash account", 20,
delegate(int transferAmount) { savings.TransferTo(cash, transferAmount); })
.Then("my savings account balance should be", 80,
delegate(int expectedBalance) { Specify.That(savings.Balance).ShouldEqual(expectedBalance); })
.And("my cash account balance should be", 30,
delegate(int expectedBalance) { Specify.That(cash.Balance).ShouldEqual(expectedBalance); })
.Given("my savings account balance is", 400)
.And("my cash account balance is", 100)
.When("I transfer to cash account", 100)
.Then("my savings account balance should be", 300)
.And("my cash account balance should be", 200)
.Given("my savings account balance is", 500)
.And("my cash account balance is", 20)
.When("I transfer to cash account", 30)
.Then("my savings account balance should be", 470)
.And("my cash account balance should be", 50);
transferStory
.WithScenario("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);
}