<commit_before>﻿@using FakeItEasy;
@using Domain;
@using Shouldly;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>RDD - Razor driven development</title>
</head>
<body>
  <h1>RDD - Razor driven development - The first bankaccount specs</h1>

<p>
    This is an example of a BDD/CQRS approach using the following tools:
</p>
<ul>
<li>An empty ASP.Net project</li>
<li>FakeItEasy</li>
<li>ShouldLy</li>
<li>Razor templates</li>
</ul>
<p>
    Works pretty sweet IMO...
</p>
<p> ToJans@twitter
</p>
   
<pre>
    **************
    * DEPOSITING *
    **************

     Deposit some money
     ------------------

        Given a bankaccount                                     @{ var SUT = Builder.ABankAccount;}

        When we deposit an amount                               @{ SUT.Account.Deposit(100); }

        Then the amount should have been deposited              @{ A.CallTo(() => SUT.Changes.AmountDeposited(100)).MustHaveHappened(); }


     Deposit a negative amount
     -------------------------

        Given a bankaccount                                     @{ SUT = Builder.ABankAccount;}

        When we deposit a negative amount                       @{ Should.Throw<InvalidOperationException>(()=> SUT.Account.Deposit(-100)); }

        Then the amount should have been deposited              @{ A.CallTo(() => SUT.Changes.AmountDeposited(A<decimal>.Ignored)).MustNotHaveHappened(); }


    ***************
    * WITHDRAWING *
    ***************

     Withdraw some money
     --------------------

        Given a bankaccount with some money on it               @{ SUT = Builder.ABankAccount.WithSomeMoneyOnIt(100);}

        When we withdraw a small amount from the account        @{ Should.NotThrow(()=> SUT.Account.Withdraw(20)); }

        Then the small amount should have been credited         @{ A.CallTo(() => SUT.Changes.AmountWithDrawn(20)).MustHaveHappened(); }


     Withdrawing a negative amount should fail
     ------------------------------------------

        Given a bankaccount with some money on it               @{ SUT = Builder.ABankAccount.WithSomeMoneyOnIt(100);}

        When we withdraw a negative amount from the account     @{ Should.Throw<InvalidOperationException>(()=> SUT.Account.Withdraw(-20));}

        Then the negative amount should not have been withdrawn @{ A.CallTo(() => SUT.Changes.AmountWithDrawn(20)).MustNotHaveHappened(); }


     Withdrawing an amount that is to large should fail
     --------------------------------------------------

        Given a bankaccount with some money on it               @{ SUT = Builder.ABankAccount.WithSomeMoneyOnIt(100);}

        When we withdraw an amount that is to large             @{ Should.Throw<InvalidOperationException>(()=> SUT.Account.Withdraw(120));}

        Then the to large amount should not have been withdrawn @{ A.CallTo(() => SUT.Changes.AmountWithDrawn(A<decimal>.Ignored)).MustNotHaveHappened(); }

</pre>
</body>
</html>
<commit_msg>Fixed typo in spec<commit_after>﻿@using FakeItEasy;
@using Domain;
@using Shouldly;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>RDD - Razor driven development</title>
</head>
<body>
  <h1>RDD - Razor driven development - The first bankaccount specs</h1>

<p>
    This is an example of a BDD/CQRS approach using the following tools:
</p>
<ul>
<li>An empty ASP.Net project</li>
<li>FakeItEasy</li>
<li>ShouldLy</li>
<li>Razor templates</li>
</ul>
<p>
    Works pretty sweet IMO...
</p>
<p> <EMAIL>
</p>
   
<pre>
    **************
    * DEPOSITING *
    **************

     Deposit some money
     ------------------

        Given a bankaccount                                     @{ var SUT = Builder.ABankAccount;}

        When we deposit an amount                               @{ SUT.Account.Deposit(100); }

        Then the amount should have been deposited              @{ A.CallTo(() => SUT.Changes.AmountDeposited(100)).MustHaveHappened(); }


     Deposit a negative amount
     -------------------------

        Given a bankaccount                                     @{ SUT = Builder.ABankAccount;}

        When we deposit a negative amount                       @{ Should.Throw<InvalidOperationException>(()=> SUT.Account.Deposit(-100)); }

        Then the amount should not have been deposited          @{ A.CallTo(() => SUT.Changes.AmountDeposited(A<decimal>.Ignored)).MustNotHaveHappened(); }


    ***************
    * WITHDRAWING *
    ***************

     Withdraw some money
     --------------------

        Given a bankaccount with some money on it               @{ SUT = Builder.ABankAccount.WithSomeMoneyOnIt(100);}

        When we withdraw a small amount from the account        @{ Should.NotThrow(()=> SUT.Account.Withdraw(20)); }

        Then the small amount should have been credited         @{ A.CallTo(() => SUT.Changes.AmountWithDrawn(20)).MustHaveHappened(); }


     Withdrawing a negative amount should fail
     ------------------------------------------

        Given a bankaccount with some money on it               @{ SUT = Builder.ABankAccount.WithSomeMoneyOnIt(100);}

        When we withdraw a negative amount from the account     @{ Should.Throw<InvalidOperationException>(()=> SUT.Account.Withdraw(-20));}

        Then the negative amount should not have been withdrawn @{ A.CallTo(() => SUT.Changes.AmountWithDrawn(20)).MustNotHaveHappened(); }


     Withdrawing an amount that is to large should fail
     --------------------------------------------------

        Given a bankaccount with some money on it               @{ SUT = Builder.ABankAccount.WithSomeMoneyOnIt(100);}

        When we withdraw an amount that is to large             @{ Should.Throw<InvalidOperationException>(()=> SUT.Account.Withdraw(120));}

        Then the to large amount should not have been withdrawn @{ A.CallTo(() => SUT.Changes.AmountWithDrawn(A<decimal>.Ignored)).MustNotHaveHappened(); }

</pre>
</body>
</html>

{'fraction_non_alphanumeric': 0.17869803416048985, 'fraction_numerical': 0.01353528843055108, 'mean_word_length': 2.123804730749874, 'pattern_counts': {'":': 0, '<': 72, '<?xml version=': 0, '>': 90, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '322003', 'n_tokens_mistral': 1867, 'n_tokens_neox': 1698, 'n_words': 472}