daily pastebin goal
91%
SHARE
TWEET

Untitled

a guest May 16th, 2018 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace Machine.Specifications.Example
  2. {
  3.   public abstract class with_from_account_and_to_account : Context
  4.   {
  5.     protected static Account fromAccount;
  6.     protected static Account toAccount;
  7.  
  8.     public override void SetupContext()
  9.     {
  10.       fromAccount = new Account { Balance = 1m };
  11.       toAccount = new Account { Balance = 1m };
  12.     }
  13.   }
  14.  
  15.   [Specification]
  16.   public class when_transfering_between_two_accounts_with_no_context
  17.   {
  18.     When the_transfer_is_made =()=>
  19.     {
  20.       fromAccount = new Account { Balance = 1m };
  21.       toAccount = new Account { Balance = 1m };
  22.       fromAccount.Transfer(1m, toAccount);
  23.     };
  24.      
  25.     It should_debit_the_from_account_by_the_ammount_transferred =()=>
  26.     {
  27.       fromAccount.Balance.ShouldEqual(0m);
  28.     };
  29.  
  30.     It should_credit_the_to_account_by_the_amount_transferred =()=>
  31.     {
  32.       toAccount.Balance.ShouldEqual(2m);
  33.     };
  34.  
  35.     protected static Account fromAccount;
  36.     protected static Account toAccount;
  37.   }
  38.  
  39.   [Specification]
  40.   public class when_transfering_between_two_accounts_has_context
  41.     : IHasContext
  42.   {
  43.     When the_transfer_is_made =()=>
  44.     {
  45.       fromAccount.Transfer(1m, toAccount);
  46.     };
  47.      
  48.     It should_debit_the_from_account_by_the_ammount_transferred =()=>
  49.     {
  50.       fromAccount.Balance.ShouldEqual(0m);
  51.     };
  52.  
  53.     It should_credit_the_to_account_by_the_amount_transferred =()=>
  54.     {
  55.       toAccount.Balance.ShouldEqual(2m);
  56.     };
  57.  
  58.     protected static Account fromAccount;
  59.     protected static Account toAccount;
  60.     public void SetupContext()
  61.     {
  62.       fromAccount = new Account { Balance = 1m };
  63.       toAccount = new Account { Balance = 1m };
  64.     }
  65.   }
  66.  
  67.   [Specification]
  68.   public class when_transfering_between_two_accounts
  69.     : with_from_account_and_to_account
  70.   {
  71.     When the_transfer_is_made =()=>
  72.     {
  73.       fromAccount.Transfer(1m, toAccount);
  74.     };
  75.      
  76.     It should_debit_the_from_account_by_the_ammount_transferred =()=>
  77.     {
  78.       fromAccount.Balance.ShouldEqual(0m);
  79.     };
  80.  
  81.     It should_credit_the_to_account_by_the_amount_transferred =()=>
  82.     {
  83.       toAccount.Balance.ShouldEqual(2m);
  84.     };
  85.   }
  86.  
  87.   [Specification]
  88.   public class when_transfering_an_amount_greater_than_the_balance_of_the_from_account
  89.     : with_from_account_and_to_account
  90.   {
  91.     When the_transfer_is_made =()=>
  92.     {
  93.       fromAccount.Transfer(2m, toAccount);
  94.     };
  95.  
  96.     It should_not_allow_the_transfer =()=>
  97.     {
  98.       exception.ShouldNotBeNull();
  99.     };
  100.  
  101.     It should_raise_System_Exception =()=>
  102.     {
  103.       exception.ShouldBeOfType(typeof(Exception));
  104.     };
  105.   }
  106. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top