public void GetAccountsByClient_NoAccountFound()
        {
            IOperationRepository operationRepository = new OperationRepository(NHibernateHelper.SessionFactory);
            IAccountRepository accountRepository = new AccountRepository(NHibernateHelper.SessionFactory, operationRepository);
            Repository repository = new Repository(NHibernateHelper.SessionFactory);

            Client client1 = new Client { LastName = "Aaa", FirstName = "Bbb", StartDate = DateTime.Now };
            Client client2 = new Client { LastName = "Ccc", FirstName = "Ddd", StartDate = DateTime.Now };
            Account account1 = new Account { AccountHolder = client1, OpeningDate = DateTime.Now };
            Account account2 = new Account { AccountHolder = client1, OpeningDate = DateTime.Now };

            using (ITransaction transaction = NHibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(client1);
                repository.Save(client2);
                repository.Save(account1);

                repository.Flush();

                IList<Account> accounts = accountRepository.GetAccountsByClient(client2.Id);
                Assert.AreEqual(0, accounts.Count);
            }
        }
        public void GetBalance_WithNoOperations()
        {
            IOperationRepository operationRepository = _mocks.Stub<IOperationRepository>();
            IAccountRepository accountRepository = new AccountRepository(NHibernateHelper.SessionFactory, operationRepository);

            Client client1 = new Client { LastName = "Aaa", FirstName = "Bbb", StartDate = DateTime.Now };
            Client client2 = new Client { LastName = "Ccc", FirstName = "Ddd", StartDate = DateTime.Now };
            Account account1 = new Account { AccountHolder = client1, OpeningDate = DateTime.Now };
            Account account2 = new Account { AccountHolder = client1, OpeningDate = DateTime.Now };

            Expect.Call(operationRepository.GetOperationsByAccount(account1.Id))
                .Return(new List<Operation>());

            _mocks.ReplayAll();

            Assert.AreEqual(0,  accountRepository.GetBalance(account1.Id));

            _mocks.VerifyAll();
        }
        public void GetBalance_WithSomeOperations()
        {
            IOperationRepository operationRepository = _mocks.Stub<IOperationRepository>();
            IAccountRepository accountRepository = new AccountRepository(NHibernateHelper.SessionFactory, operationRepository);

            Client client1 = new Client { LastName = "Aaa", FirstName = "Bbb", StartDate = DateTime.Now };
            Client client2 = new Client { LastName = "Ccc", FirstName = "Ddd", StartDate = DateTime.Now };
            Account account1 = new Account { AccountHolder = client1, OpeningDate = DateTime.Now };
            Account account2 = new Account { AccountHolder = client1, OpeningDate = DateTime.Now };

            Operation operation1 = new Operation { Account = account1, OperationType = OperationType.Deposit, Amount = 10000, Date = DateTime.Now };
            Operation operation2 = new Operation { Account = account1, OperationType = OperationType.Withdraw, Amount = 1000, Date = DateTime.Now };
            Operation operation3 = new Operation { Account = account1, OperationType = OperationType.Withdraw, Amount = 5000, Date = DateTime.Now };
            Operation operation4 = new Operation { Account = account1, OperationType = OperationType.Deposit, Amount = 30000, Date = DateTime.Now };

            Expect.Call(operationRepository.GetOperationsByAccount(account1.Id))
                .Return(new List<Operation> { operation1, operation2, operation3, operation4 });

            _mocks.ReplayAll();

            Assert.AreEqual(34000, accountRepository.GetBalance(account1.Id));

            _mocks.VerifyAll();
        }