BDD: Implementation og tilbageblik
Thursday, July 24th, 2008Nedenfor er vist min første implementation af kode i EconomyDeluxe:
using System;
using Domain.Interfaces;
using System.Collections.Generic;
using System.Collections;
public class GeneralLedger:IGeneralLedger
{
private Dictionary _accounts;
public GeneralLedger()
{
_accounts = new Dictionary();
}
public void AddAccount(ILedgerAccount account)
{
if (account == null)
{
throw new ArgumentNullException(“Null account supplied”);
}
if (!account.IsValid)
{
throw new ArgumentException(“Invalid account”);
}
if (_accounts.ContainsKey(account.AccountId))
{
throw new ArgumentOutOfRangeException(“AccountId is already present”);
}
_accounts.Add(account.AccountId,account);
}
public void DeleteAccount(ILedgerAccount account)
{
if (account == null)
{
throw new ArgumentNullException(“Null account supplied”);
}
if (!_accounts.ContainsKey(account.AccountId))
{
throw new ArgumentOutOfRangeException(“AccountId [...]