Пример #1
1
        public void GetAccountsByCustomerSomeAccountsFound()
        {
            IAccountRepository accountRepository = new AccountRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer thirdParty1 = new Customer { Code = "tjdsklfs", Email = "*****@*****.**", LastName = "roux", FirstName = "Olivier", Password = "******", PasswordSalt = "sss" };
            Customer thirdParty2 = new Customer { Code = "topsecret", Email = "*****@*****.**", LastName = "roux2", FirstName = "Olivier", Password = "******", PasswordSalt = "sss" };

            Account account1 = new Account { Balance = 201, BalanceDate = DateTime.Now, Number = "dsf1", Iban="12354"};
            Account account2 = new Account { Balance = 202, BalanceDate = DateTime.Now, Number = "dsf2", Iban="12435"};

            Role role = new Role{Id=1};
            thirdParty1.RelatedAccounts.Add(account1, role);
            thirdParty1.RelatedAccounts.Add(account2, role);

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(thirdParty1);
                repository.Save(thirdParty2);
                repository.Save(account1);
                repository.Save(account2);

                repository.Flush();

                IList<Account> accounts = accountRepository.GetAccountsByCustomer(thirdParty1.Id);
                Assert.AreEqual(2, accounts.Count);
            }
        }
Пример #2
0
        public void GetAccountByCustomerNoAccountFound()
        {
            IAccountRepository accountRepository = new AccountRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer thirdParty1 = new Customer { Code = "tjdsklfs", Email = "*****@*****.**", LastName = "Roux", FirstName = "Olivier", Password = "******", PasswordSalt = "sss" };
            Customer thirdParty2 = new Customer { Code = "topsecret", Email = "*****@*****.**", LastName = "Roux2", FirstName = "Olivier", Password = "******", PasswordSalt = "sss" };
            Account account1 = new Account { Balance = 201, BalanceDate = DateTime.Now, Number = "dsf1", Iban="12349340943"};

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(thirdParty1);
                repository.Save(thirdParty2);
                repository.Save(account1);

                repository.Flush();

                IList<Account> accounts = accountRepository.GetAccountsByCustomer(thirdParty2.Id);
                Assert.AreEqual(0, accounts.Count);
            }
        }