public void CanDeposit()
        {
            var bank = new Bank();
            var account = bank.OpenAccount();
            account.Deposit(10);

            Assert.AreEqual(10, account.Balance.Amount);
        }
        public void CanReturnReservation()
        {
            var bank = new Bank();
            var account = bank.OpenAccount(100);

            using (var reservation = account.Reserve(50, TimeSpan.MaxValue)) {
                Assert.IsTrue(reservation.Awarded);
                Assert.AreEqual(50, account.Available.Amount);
            }

            Assert.AreEqual(100, account.Available.Amount);
        }
        public void CanReserve()
        {
            var bank = new Bank();
            var account = bank.OpenAccount(100);

            using (var reservation = account.Reserve(50, TimeSpan.FromSeconds(1))) {
                Assert.IsTrue(reservation.Awarded);
                Assert.AreEqual(50, account.Available);

                Thread.Sleep(TimeSpan.FromSeconds(1));
                Assert.AreEqual(100, account.Available);
            }
        }
        public void CanReserveMultiple()
        {
            var bank = new Bank();
            var account = bank.OpenAccount(100);

            using (var reserve50 = account.Reserve(50, TimeSpan.FromSeconds(1)))
            using (var reserve25 = account.Reserve(25, TimeSpan.FromSeconds(2))) {

                Assert.AreEqual(true, reserve50.Awarded);
                Assert.AreEqual(true, reserve25.Awarded);
                Assert.AreEqual(25, account.Available);

                Thread.Sleep(TimeSpan.FromSeconds(1));
                Assert.AreEqual(75, account.Available);

                Thread.Sleep(TimeSpan.FromSeconds(1));
                Assert.AreEqual(100, account.Available);
            }
        }
        public void CanSplitAccount()
        {
            var bank = new Bank();
            var account = bank.OpenAccount(100);
            var split = bank.SplitAccount(account, 50);

            Assert.AreEqual(50, account.Balance.Amount);
            Assert.AreEqual(50, split.Balance.Amount);
        }
 public void WithdrawEnforcesBalance()
 {
     var bank = new Bank();
     var account = bank.OpenAccount();
     account.Deposit(5M);
     account.Withdraw(10M);
 }