Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Introducing BDDfy: the simplest BDD framework for .Net

, 23 Sep 2013
This article is an introduction to installing and using bddify - a simple to use and extend BDD framework for .NET developers.
Bddify.Samples.Net4.zip
Bddify.Samples
Bddify.Samples.Atm
Bddify.Samples.suo
Bddify.Samples.TicTacToe
packages
Bddify.0.8
Bddify.0.8.nupkg
content
lib
NET35
Bddify.dll
NET40
Bddify.dll
SL4
Bddify.dll
Bddify.Samples.Atm.0.8
Bddify.Samples.Atm.0.8.nupkg
content
Bddify.Samples.Atm
Bddify.Samples.TicTacToe.0.8
Bddify.Samples.TicTacToe.0.8.nupkg
content
Bddify.Samples.TicTacToe
NUnit.2.5.10.11092
lib
nunit.framework.dll
nunit.mocks.dll
pnunit.framework.dll
Logo.ico
NUnit.2.5.10.11092.nupkg
tools
agent.conf
agent.log.conf
launcher.log.conf
lib
Failure.png
fit.dll
Ignored.png
Inconclusive.png
log4net.dll
nunit-console-runner.dll
nunit-gui-runner.dll
nunit.core.dll
nunit.core.interfaces.dll
nunit.fixtures.dll
nunit.uiexception.dll
nunit.uikit.dll
nunit.util.dll
Skipped.png
Success.png
nunit-agent-x86.exe
nunit-agent.exe
nunit-console-x86.exe
nunit-console.exe
nunit-x86.exe
nunit.exe
nunit.framework.dll
NUnitTests.nunit
pnunit-agent.exe
pnunit-launcher.exe
pnunit.framework.dll
pnunit.tests.dll
runFile.exe
test.conf
RazorEngine.2.1
lib
.NetFramework 4.0
RazorEngine.dll
System.Web.Razor.dll
RazorEngine.2.1.nupkg
Properties
Bddify.Samples.V0.9.zip
Bddify.Samples.suo
Bddify.0.9
Bddify.0.9.nupkg
content
lib
NET35
Bddify.dll
NET40
Bddify.dll
SL4
Bddify.dll
Bddify.Samples.Atm.0.9
Bddify.Samples.Atm.0.9.nupkg
content
Bddify.Samples.Atm
Bddify.Samples.TicTacToe.0.9
Bddify.Samples.TicTacToe.0.9.nupkg
content
Bddify.Samples.TicTacToe
nunit.framework.dll
nunit.mocks.dll
pnunit.framework.dll
Logo.ico
NUnit.2.5.10.11092.nupkg
agent.conf
agent.log.conf
launcher.log.conf
Failure.png
fit.dll
Ignored.png
Inconclusive.png
log4net.dll
nunit-console-runner.dll
nunit-gui-runner.dll
nunit.core.dll
nunit.core.interfaces.dll
nunit.fixtures.dll
nunit.uiexception.dll
nunit.uikit.dll
nunit.util.dll
Skipped.png
Success.png
nunit-agent-x86.exe
nunit-agent.exe
nunit-console-x86.exe
nunit-console.exe
nunit-x86.exe
nunit.exe
nunit.framework.dll
NUnitTests.nunit
pnunit-agent.exe
pnunit-launcher.exe
pnunit.framework.dll
pnunit.tests.dll
runFile.exe
test.conf
RazorEngine.dll
System.Web.Razor.dll
RazorEngine.2.1.nupkg
using Bddify.Scanners.StepScanners.ExecutableAttribute.GwtAttributes;
using NUnit.Framework;

namespace Bddify.Samples.Atm
{
    public class AccountHasInsufficientFund
    {
        private Card _card;
        private Atm _atm;

		// You can override step text using executable attributes
		[Given(StepText = "Given the account balance is $10")]
        void GivenTheAccountBalanceIs10()
        {
            _card = new Card(true, 10);
        }

        void AndGivenTheCardIsValid()
        {
        }

        void AndGivenTheMachineContainsEnoughMoney()
        {
            _atm = new Atm(100);
        }

		[When(StepText = "When the account holder requests $20")]
        void WhenTheAccountHolderRequests20()
        {
            _atm.RequestMoney(_card, 20);
        }

        void ThenTheAtmShouldNotDispenseAnyMoney()
        {
            Assert.AreEqual(0, _atm.DispenseValue);
        }

        void AndTheAtmShouldSayThereAreInsufficientFunds()
        {
            Assert.AreEqual(DisplayMessage.InsufficientFunds, _atm.Message);
        }

		[AndThen(StepText = "And the account balance should be $20")]
        void AndTheAccountBalanceShouldBe20()
        {
            Assert.AreEqual(10, _card.AccountBalance);
        }

        void AndTheCardShouldBeReturned()
        {
            Assert.IsFalse(_atm.CardIsRetained);
        }
    }
}

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)

Share

About the Author

Mehdi Khalili
Software Developer (Senior) ThoughtWorks
United States United States
I work as a Senior Consultant for ThoughtWorks
Follow on   Twitter   Google+   LinkedIn

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 23 Sep 2013
Article Copyright 2011 by Mehdi Khalili
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid