예제 #1
0
        private void DeleteInitialData()
        {
            IPayrollRepository repository = new PayrollRepository();
            foreach (var payroll in _payrolls)
            {
                Payroll fromDb = repository.GetById(payroll.PayrollId);
                if (fromDb != null)
                {
                    repository.Remove(payroll);
                }
            }

            ICompanyRepository companyRepository = new CompanyRepository();
            companyRepository.Remove(_company1);
            companyRepository.Remove(_company2);
        }
예제 #2
0
        public void Can_add_new_payroll()
        {
            var payroll = new Payroll { PayrollStartDate = DateTime.Now, PayrollNumberOfWeeks = 2 };
            // Get rid of milliseconds to make comparisons work, since MySQL
            // DateTime does not support milliseconds.
            payroll.PayrollStartDate = DateTime.ParseExact(payroll.PayrollStartDate.ToString(), "M/d/yyyy h:mm:ss tt", null);
            payroll.Company = _company1;
            IPayrollRepository repository = new PayrollRepository();
            repository.Add(payroll);

            // use session to try to load the payroll
            using (ISession session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<Payroll>(payroll.PayrollId);
                // Test that the payroll was successfully inserted
                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(payroll, fromDb);
                Assert.AreEqual(payroll.PayrollNumberOfWeeks, fromDb.PayrollNumberOfWeeks);
                Assert.AreEqual(payroll.PayrollStartDate, fromDb.PayrollStartDate);
            }

            repository.Remove(payroll);
        }
예제 #3
0
        public void Can_remove_existing_payroll()
        {
            var payroll = _payrolls[0];
            IPayrollRepository repository = new PayrollRepository();
            repository.Remove(payroll);

            using (ISession session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<Payroll>(payroll.PayrollId);
                Assert.IsNull(fromDb);
            }
        }