コード例 #1
0
        /// <summary>
        /// Test Find using the Query class
        /// </summary>
        private void Step_30_TestFindByQuery_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                //Insert Mock Instance
                Employee mock   = CreateMockInstance(tm);
                bool     result = DataRepository.EmployeeProvider.Insert(tm, mock);

                Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed");

                EmployeeQuery query = new EmployeeQuery();

                query.AppendEquals(EmployeeColumn.EmployeeId, mock.EmployeeId.ToString());
                query.AppendEquals(EmployeeColumn.NationalIdNumber, mock.NationalIdNumber.ToString());
                query.AppendEquals(EmployeeColumn.ContactId, mock.ContactId.ToString());
                query.AppendEquals(EmployeeColumn.LoginId, mock.LoginId.ToString());
                if (mock.ManagerId != null)
                {
                    query.AppendEquals(EmployeeColumn.ManagerId, mock.ManagerId.ToString());
                }
                query.AppendEquals(EmployeeColumn.Title, mock.Title.ToString());
                query.AppendEquals(EmployeeColumn.BirthDate, mock.BirthDate.ToString());
                query.AppendEquals(EmployeeColumn.MaritalStatus, mock.MaritalStatus.ToString());
                query.AppendEquals(EmployeeColumn.Gender, mock.Gender.ToString());
                query.AppendEquals(EmployeeColumn.HireDate, mock.HireDate.ToString());
                query.AppendEquals(EmployeeColumn.SalariedFlag, mock.SalariedFlag.ToString());
                query.AppendEquals(EmployeeColumn.VacationHours, mock.VacationHours.ToString());
                query.AppendEquals(EmployeeColumn.SickLeaveHours, mock.SickLeaveHours.ToString());
                query.AppendEquals(EmployeeColumn.CurrentFlag, mock.CurrentFlag.ToString());
                query.AppendEquals(EmployeeColumn.Rowguid, mock.Rowguid.ToString());
                query.AppendEquals(EmployeeColumn.ModifiedDate, mock.ModifiedDate.ToString());

                TList <Employee> results = DataRepository.EmployeeProvider.Find(tm, query);

                Assert.IsTrue(results.Count == 1, "Find is not working correctly.  Failed to find the mock instance");
            }
        }