Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: a055c91369
Fetching contributors…

Cannot retrieve contributors at this time

46 lines (37 sloc) 1.322 kb
using System;
namespace Machine.Specifications.Example.CustomDelegates
{
[Subject(typeof(Account), "Funds transfer")]
public class when_transferring_between_two_accounts
{
static Account fromAccount;
static Account toAccount;
Given accounts = () =>
{
fromAccount = new Account {Balance = 1m};
toAccount = new Account {Balance = 1m};
};
When transfer_is_made =
() => fromAccount.Transfer(1m, toAccount);
Then should_debit_the_from_account_by_the_amount_transferred =
() => fromAccount.Balance.ShouldEqual(0m);
Then should_credit_the_to_account_by_the_amount_transferred =
() => toAccount.Balance.ShouldEqual(2m);
}
[Subject(typeof(Account), "Funds transfer")]
public class when_transferring_an_amount_larger_than_the_balance_of_the_from_account
{
static Account fromAccount;
static Account toAccount;
static Exception exception;
Given accounts = () =>
{
fromAccount = new Account {Balance = 1m};
toAccount = new Account {Balance = 1m};
};
Because transfer_is_made =
() => exception = Catch.Exception(() => fromAccount.Transfer(2m, toAccount));
Then should_not_allow_the_transfer =
() => exception.ShouldBeOfType<Exception>();
}
}
Jump to Line
Something went wrong with that request. Please try again.