コード例 #1
0
        public void FindIndividualCustomersByName()
        {
            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" };

            IList<Customer> customers1;
            IList<Customer> customers2;
            IList<Customer> customers3;

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

                String[] names1 = { customer.FirstName };
                String[] names2 = { customer.LastName };
                String[] names3 = { customer.FirstName, customer.LastName };

                customers1 = customerRepository.FindCustomersByName(names1);
                customers2 = customerRepository.FindCustomersByName(names2);
                customers3 = customerRepository.FindCustomersByName(names3);

                Assert.IsNotNull(customers1);
                Assert.IsNotNull(customers2);
                Assert.IsNotNull(customers3);

            }
            Assert.AreEqual("*****@*****.**", customers1[0].Email);
            Assert.AreEqual("*****@*****.**", customers2[0].Email);
            Assert.AreEqual("*****@*****.**", customers3[0].Email);
        }
コード例 #2
0
        public void GetCustomerByIdentity_Found_NotFound()
        {
            ICustomerRepository customerRepository = new CustomerRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer customer = new Customer { Code = "tjdsklfs", 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.GetCustomerByIdentity(customer.Identification);
                notFoundCustomer = customerRepository.GetCustomerByIdentity("a");
            }
            Assert.IsNull(notFoundCustomer);
            Assert.IsNotNull(foundCustomer);
            Assert.AreEqual("*****@*****.**", foundCustomer.Email);
        }
コード例 #3
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);
            }
        }
コード例 #4
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);
            }
        }