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 CPOL
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
namespace Bddify.Samples.Atm
{
    public class Atm
    {
        public int ExistingCash { get; private set; }

        public Atm(int existingCash)
        {
            ExistingCash = existingCash;
        }

        public void RequestMoney(Card card, int request)
        {
            if (!card.Enabled)
            {
                CardIsRetained = true;
                Message = DisplayMessage.CardIsRetained;
                return;
            }

            if(card.AccountBalance < request)
            {
                Message = DisplayMessage.InsufficientFunds;
                return;
            }

            DispenseValue = request;
            card.AccountBalance -= request;
        }

        public int DispenseValue { get; set; }

        public bool CardIsRetained { get; private set; }

        public DisplayMessage Message { get; private set; }
    }

    public class Card
    {
        public int AccountBalance { get; set; }
        private readonly bool _enabled;

        public Card(bool enabled, int accountBalance)
        {
            AccountBalance = accountBalance;
            _enabled = enabled;
        }

        public bool Enabled
        {
            get { return _enabled; }
        }
    }

    public enum DisplayMessage
    {
        None = 0,
        CardIsRetained,
        InsufficientFunds
    }
}

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 | Terms of Use | Mobile
Web04 | 2.8.1411028.1 | Last Updated 23 Sep 2013
Article Copyright 2011 by Mehdi Khalili
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid