Click here to Skip to main content
15,885,546 members
Articles / Programming Languages / C#

Getting started with BDD (Behavior Driven Development) in .NET

Rate me:
Please Sign up or sign in to vote.
4.68/5 (11 votes)
9 Nov 2009CPOL8 min read 80.2K   554   28  
This article is a lean and mean/quick intro on how to get started with BDD in .NET.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Be.Corebvba.Aubergine;

namespace Com.CodeProject.BDDExample
{
    class Account_Holder_withdraws_cash : Story<AccountContext>
    {
        As_an Account_Holder;
        I_want to_withdraw_cash_from_an_ATM;
        So_that I_can_get_money_when_the_bank_is_closed;
        class Account_has_sufficient_funds : Scenario
        {
            Given the_account_balance_is_100;
            Given the_card_is_valid;
            Given the_machine_contains_enough_money;
            When the_Account_Holder_requests_20;
            Then the_ATM_should_dispense_20;
            Then the_account_balance_should_be_80;
            Then the_card_should_be_returned;
        }
        class Account_has_insufficient_funds : Scenario
        {
            Given the_account_balance_is_10;
            Given the_card_is_valid;
            Given the_machine_contains_enough_money;
            When the_Account_Holder_requests_20;
            Then the_ATM_should_not_dispense_any_money;
            Then the_ATM_should_say_there_are_insufficient_funds;
            Then the_account_balance_should_be_10;
            Then the_card_should_be_returned;
        }
        class Card_has_been_disabled : Scenario
        {
            Given the_card_is_disabled;
            When the_Account_Holder_requests_20;
            Then the_ATM_should_retain_the_card;
            Then the_ATM_should_say_the_card_has_been_retained;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder Virtual Sales Lab
Belgium Belgium

Comments and Discussions