Ejemplo n.º 1
0
        public void GetCustomerByCode_Found_NotFound()
        {
            ICustomerRepository customerRepository = new CustomerRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer customer = new Customer { Code = "someCode", Email = "*****@*****.**", FirstName = "Sim", LastName = "Lehericey", Password = "******", Identification = "Ident", PasswordSalt = "sss" };

            Customer foundCustomer;
            Customer notFoundCustomer;

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(customer);
                repository.Flush();

                foundCustomer = customerRepository.GetCustomerByCode(customer.Code);
                notFoundCustomer = customerRepository.GetCustomerByCode("a");
            }
            Assert.IsNull(notFoundCustomer);
            Assert.IsNotNull(foundCustomer);
            Assert.AreEqual("*****@*****.**", foundCustomer.Email);
        }
Ejemplo n.º 2
0
        public void GetIndividualCustomerByCode_NotFound()
        {
            ICustomerRepository thirdPartyRepository = new CustomerRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer individualThirdParty1 = new Customer { Code = "tjdsklfs", Email = "*****@*****.**", FirstName = "Sim", LastName = "Lehericey", Password = "******", PasswordSalt = "sss" };

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(individualThirdParty1);
                repository.Flush();

                Customer individualThirdPartyRetrieved = thirdPartyRepository.GetCustomerByCode("a");
                Assert.IsNull(individualThirdPartyRetrieved);
            }
        }
Ejemplo n.º 3
0
        public void GetIndividualCustomerByCode_Found()
        {
            ICustomerRepository customerRepository = new CustomerRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer customer = new Customer { Code = "tjdsklfs", Email = "*****@*****.**", FirstName = "Sim", LastName = "Lehericey", Password = "******", PasswordSalt = "sss" };
            Account account1 = new Account { Balance = 201, BalanceDate = DateTime.Now, Number = "dsf1", Iban="1234"};

            Customer retrievedCustomer;

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(customer);
                repository.Save(account1);
                repository.Flush();

                retrievedCustomer = customerRepository.GetCustomerByCode(customer.Code);
                Assert.IsNotNull(retrievedCustomer);
            }
        }