public void TestLeaveTypeTimeStamp() { // Insert a leave type DateTime startTime = Convert.ToDateTime("01/01/2000"); DateTime endTime = Convert.ToDateTime("01/01/3000"); LeaveType leaveType = LeaveType.CreateLeaveType(Guid.NewGuid().ToString(), 100, startTime, endTime); leaveType.PKLeaveTypeID = Guid.NewGuid(); leaveType.SetKnowledgeDate(DateTime.Now); leaveType.Save(); Guid guid = leaveType.PKLeaveTypeID; // Get the leave type inserted just now List <SearchCondition> conditions = new List <SearchCondition>(); conditions.Add(SearchCondition.CreateSearchCondition("PKLeaveTypeID", guid.ToString(), SearchComparator.Equal, SearchType.SearchString)); LeaveType testLeaveType1 = CommonDAL <LeaveType> .GetSingleObject(conditions); LeaveType testLeaveType2 = CommonDAL <LeaveType> .GetSingleObject(conditions); // Update the leave type inserted just now testLeaveType1.Name = "UpdatedLeaveType"; testLeaveType1.Save(); testLeaveType2.Name = "SecUpdatedLeaveType"; testLeaveType2.Save(); // Get the leave type updated just now LeaveType updatedLeaveType = CommonDAL <LeaveType> .GetSingleObject(conditions); Assert.AreEqual(testLeaveType1.Name, updatedLeaveType.Name); Assert.AreNotEqual(testLeaveType2.Name, updatedLeaveType.Name); // Delete the leave type leaveType.Delete(); }
public void TestDeleteEmployeeLeaveSummary() { // Insert an employee role Role employeeRole = Role.CreateRole(Guid.NewGuid().ToString()); employeeRole.Save(); // Insert an employee. Employee employee = Employee.CreateEmployee(Guid.NewGuid().ToString(), "123", Sex.Male, "Tian", DateTime.Now, "Liu"); employee.IsActive = true; employee.ServiceYears = 10; List <EmployeeRoleRL> employeeRoleList = new List <EmployeeRoleRL>(); employeeRoleList.Add(EmployeeRoleRL.CreateEmployeeRoleRL(Guid.Empty, employeeRole.PKRoleID)); employee.SetRoleList(employeeRoleList); employee.Save(); Guid employeeGuid = employee.PKEmployeeID; // Insert a leave type DateTime leaveTypeStartTime = Convert.ToDateTime("01/01/2000"); DateTime leaveTypeEndTime = Convert.ToDateTime("01/01/3000"); LeaveType leaveType = LeaveType.CreateLeaveType(Guid.NewGuid().ToString(), 100, leaveTypeStartTime, leaveTypeEndTime); leaveType.PKLeaveTypeID = Guid.NewGuid(); leaveType.SetKnowledgeDate(DateTime.Now); leaveType.Save(); Guid leaveTypeGuid = leaveType.PKLeaveTypeID; // Insert an employee leave summary EmployeeLeaveSummary employeeLeaveSummary = EmployeeLeaveSummary.CreateEmployeeLeaveSummary(employeeGuid, leaveTypeGuid, DateTime.Now.Year); employeeLeaveSummary.PKELSID = Guid.NewGuid(); employeeLeaveSummary.UsedHours = 10; employeeLeaveSummary.Save(); Guid summaryGuid = employeeLeaveSummary.PKELSID; // Delete the employee leave summary employeeLeaveSummary.Delete(); // Get the inserted employee leave summary List <SearchCondition> conditions = new List <SearchCondition>(); conditions.Add(SearchCondition.CreateSearchCondition("PKELSID", summaryGuid.ToString(), SearchComparator.Equal, SearchType.SearchString)); EmployeeLeaveSummary testSummary = CommonDAL <EmployeeLeaveSummary> .GetSingleObject(conditions); Assert.IsNull(testSummary); // Delete inserted items leaveType.Delete(); employee.Delete(); employeeRole.Delete(); }
public void TestDeleteLeaveType() { // Insert a leave type DateTime startTime = Convert.ToDateTime("01/01/2000"); DateTime endTime = Convert.ToDateTime("01/01/3000"); LeaveType leaveType = LeaveType.CreateLeaveType(Guid.NewGuid().ToString(), 100, startTime, endTime); leaveType.PKLeaveTypeID = Guid.NewGuid(); leaveType.SetKnowledgeDate(DateTime.Now); leaveType.Save(); // Delete the leave type leaveType.Delete(); // Get the leave type deleted just now Guid guid = leaveType.PKLeaveTypeID; List <SearchCondition> conditions = new List <SearchCondition>(); conditions.Add(SearchCondition.CreateSearchCondition("PKLeaveTypeID", guid.ToString(), SearchComparator.Equal, SearchType.SearchString)); LeaveType testLeaveType = CommonDAL <LeaveType> .GetSingleObject(conditions); Assert.IsNull(testLeaveType); }
public void TestTimeDurationInfoTimeStamp() { // Insert an employee role Role employeeRole = Role.CreateRole(Guid.NewGuid().ToString()); employeeRole.Save(); // Insert an employee. Employee employee = Employee.CreateEmployee(Guid.NewGuid().ToString(), "123", Sex.Male, "Tian", DateTime.Now, "Liu"); employee.IsActive = true; employee.ServiceYears = 10; List <EmployeeRoleRL> employeeRoleList = new List <EmployeeRoleRL>(); employeeRoleList.Add(EmployeeRoleRL.CreateEmployeeRoleRL(Guid.Empty, employeeRole.PKRoleID)); employee.SetRoleList(employeeRoleList); employee.Save(); Guid employeeGuid = employee.PKEmployeeID; // Insert a manager role Role managerRole = Role.CreateRole(Guid.NewGuid().ToString()); managerRole.Save(); // Insert an employee who is a manager Employee manager = Employee.CreateEmployee(Guid.NewGuid().ToString(), "123", Sex.Female, "Helen", DateTime.Now, "Niu"); manager.IsActive = true; manager.ServiceYears = 8; List <EmployeeRoleRL> managerRoleList = new List <EmployeeRoleRL>(); managerRoleList.Add(EmployeeRoleRL.CreateEmployeeRoleRL(Guid.Empty, managerRole.PKRoleID)); manager.SetRoleList(managerRoleList); manager.Save(); Guid managerGuid = manager.PKEmployeeID; // Insert a leave type DateTime leaveTypeStartTime = Convert.ToDateTime("01/01/2000"); DateTime leaveTypeEndTime = Convert.ToDateTime("01/01/3000"); LeaveType leaveType = LeaveType.CreateLeaveType(Guid.NewGuid().ToString(), 100, leaveTypeStartTime, leaveTypeEndTime); leaveType.PKLeaveTypeID = Guid.NewGuid(); leaveType.SetKnowledgeDate(DateTime.Now); leaveType.Save(); Guid leaveTypeGuid = leaveType.PKLeaveTypeID; // Insert a leave time duration for this leave DateTime durationStartTime = Convert.ToDateTime("02/02/2001"); DateTime durationEndTime = Convert.ToDateTime("02/05/2001"); TimeDurationInfo timeDurationInfo = TimeDurationInfo.CreateTimeDurationInfo(durationStartTime, durationEndTime); List <TimeDurationInfo> timeDurationList = new List <TimeDurationInfo>(); timeDurationList.Add(timeDurationInfo); // Insert a leave info LeaveInfo leaveInfo = LeaveInfo.CreateLeaveInfo(employeeGuid, managerGuid, leaveTypeGuid, LeaveStatus.Accepted, "For Test", "Test Description", timeDurationList); leaveInfo.Save(); Guid leaveGuid = leaveInfo.PKLeaveInfoID; timeDurationInfo.FKLeaveInfoID = leaveGuid; timeDurationInfo.KnowledgeDate = DateTime.Now; timeDurationInfo.IsDeleted = false; timeDurationInfo.Save(); Guid tdGuid = timeDurationInfo.PKTDInfoID; // Get the inserted time duration info List <SearchCondition> conditions = new List <SearchCondition>(); conditions.Add(SearchCondition.CreateSearchCondition("PKTDInfoID", tdGuid.ToString(), SearchComparator.Equal, SearchType.SearchString)); TimeDurationInfo testTimeDuration1 = CommonDAL <TimeDurationInfo> .GetSingleObject(conditions); TimeDurationInfo testTimeDuration2 = CommonDAL <TimeDurationInfo> .GetSingleObject(conditions); // Update the inseted time duratioin info testTimeDuration1.EndTime = Convert.ToDateTime("02/10/2001"); testTimeDuration1.Save(); testTimeDuration2.EndTime = Convert.ToDateTime("02/11/2002"); testTimeDuration2.Save(); // Get the updated time duration info TimeDurationInfo updatedTimeDuration = CommonDAL <TimeDurationInfo> .GetSingleObject(conditions); Assert.AreEqual(testTimeDuration1.EndTime, updatedTimeDuration.EndTime); Assert.AreNotEqual(testTimeDuration2.EndTime, updatedTimeDuration.EndTime); // Delete inserted items timeDurationInfo.Delete(); leaveInfo.Delete(); leaveType.Delete(); employee.Delete(); manager.Delete(); employeeRole.Delete(); managerRole.Delete(); }
public void TestUpdateLeaveInfoTransact() { // Insert an employee role Role employeeRole = Role.CreateRole(Guid.NewGuid().ToString()); employeeRole.Save(); // Insert an employee. Employee employee = Employee.CreateEmployee(Guid.NewGuid().ToString(), "123", Sex.Male, "Tian", DateTime.Now, "Liu"); employee.IsActive = true; employee.ServiceYears = 10; List <EmployeeRoleRL> employeeRoleList = new List <EmployeeRoleRL>(); employeeRoleList.Add(EmployeeRoleRL.CreateEmployeeRoleRL(Guid.Empty, employeeRole.PKRoleID)); employee.SetRoleList(employeeRoleList); employee.Save(); Guid employeeGuid = employee.PKEmployeeID; // Insert a manager role Role managerRole = Role.CreateRole(Guid.NewGuid().ToString()); managerRole.Save(); // Insert an employee who is a manager Employee manager = Employee.CreateEmployee(Guid.NewGuid().ToString(), "123", Sex.Female, "Helen", DateTime.Now, "Niu"); manager.IsActive = true; manager.ServiceYears = 8; List <EmployeeRoleRL> managerRoleList = new List <EmployeeRoleRL>(); managerRoleList.Add(EmployeeRoleRL.CreateEmployeeRoleRL(Guid.Empty, managerRole.PKRoleID)); manager.SetRoleList(managerRoleList); manager.Save(); Guid managerGuid = manager.PKEmployeeID; // Insert a leave type DateTime leaveTypeStartTime = Convert.ToDateTime("01/01/2000"); DateTime leaveTypeEndTime = Convert.ToDateTime("01/01/3000"); LeaveType leaveType = LeaveType.CreateLeaveType(Guid.NewGuid().ToString(), 100, leaveTypeStartTime, leaveTypeEndTime); leaveType.PKLeaveTypeID = Guid.NewGuid(); leaveType.SetKnowledgeDate(DateTime.Now); leaveType.Save(); Guid leaveTypeGuid = leaveType.PKLeaveTypeID; // Insert a leave time duration for this leave DateTime durationStartTime = Convert.ToDateTime("02/02/2001"); DateTime durationEndTime = Convert.ToDateTime("02/05/2001"); TimeDurationInfo timeDurationInfo = TimeDurationInfo.CreateTimeDurationInfo(durationStartTime, durationEndTime); List <TimeDurationInfo> timeDurationList = new List <TimeDurationInfo>(); timeDurationList.Add(timeDurationInfo); // Insert a leave info LeaveInfo leaveInfo = LeaveInfo.CreateLeaveInfo(employeeGuid, managerGuid, leaveTypeGuid, LeaveStatus.Accepted, "For Test", "Test Description", timeDurationList); leaveInfo.Save(); Guid leaveGuid = leaveInfo.PKLeaveInfoID; // Get the leave info inserted just now List <SearchCondition> conditions = new List <SearchCondition>(); conditions.Add(SearchCondition.CreateSearchCondition("PKLeaveInfoID", leaveGuid.ToString(), SearchComparator.Equal, SearchType.SearchString)); LeaveInfo testLeaveInfo = CommonDAL <LeaveInfo> .GetSingleObject(conditions); // Update the leave info testLeaveInfo.Reason = "Update test leave reason"; try { testLeaveInfo.Save(); } catch { Console.WriteLine("Throw exception for transact unit test"); } // Get the updated leave info LeaveInfo updatedLeaveInfo = CommonDAL <LeaveInfo> .GetSingleObject(conditions); Assert.AreNotEqual(testLeaveInfo.Reason, updatedLeaveInfo.Reason); // Delete the leave, leave type, employees and roles leaveInfo.Delete(); leaveType.Delete(); employee.Delete(); manager.Delete(); employeeRole.Delete(); managerRole.Delete(); }