public void DeleteWorkLoadTest() { EmployeeService employeeService = new EmployeeService(uow, new Map <Employee, EmployeeDTO>()); ProjectService projectService = new ProjectService(uow, new Map <Project, ProjectDTO>()); ProjectWorkService projectWorkService = new ProjectWorkService(uow, new Map <ProjectWork, ProjectWorkDTO>()); EmployeeDTO employee1 = new EmployeeDTO { EmployeeName = "Екатерина", EmployeeSurname = "Антонович", EmployeePatronymic = "Алексеевна", RoleId = 3, Email = "*****@*****.**", }; var employeeOnWork1 = employeeService.CreateEmployee(employee1); var em1 = employeeService.GetEmployeeById(employeeOnWork1.Id); ProjectDTO project1 = new ProjectDTO { ProjectName = "проект 1", ProjectDescription = "проект номер один", ProjectStartDate = new DateTimeOffset(2021, 10, 6, 10, 15, 35, new TimeSpan(3, 0, 0)), ProjectEndDate = new DateTimeOffset(2021, 10, 21, 10, 15, 35, new TimeSpan(3, 0, 0)) }; var proj1 = projectService.CreateProject(project1); var pr1 = projectService.GetProjectById(proj1.Id); ProjectWorkDTO projectWork = new ProjectWorkDTO { EmployeeId = em1.Id, ProjectId = pr1.Id, ProjectRoleId = 3 }; var errors = pwvalidator.Validate(projectWork); var pWork = projectWorkService.CreateProjectWork(projectWork); var actual1 = projectWorkService.GetProjectWorkById(pWork.Id); projectWorkService.AddWorkLoad(actual1.Id, 20); var actual2 = projectWorkService.GetProjectWorkById(actual1.Id); projectWorkService.DeleteWorkLoad(pWork.Id); var actual = projectWorkService.GetProjectWorkById(actual2.Id); ProjectWorkDTO expected = new ProjectWorkDTO { Id = actual.Id, EmployeeId = em1.Id, ProjectId = pr1.Id, ProjectRoleId = 3, WorkLoad = null }; Assert.IsTrue(errors.Count == 0 && actual.Id == expected.Id && actual.EmployeeId == expected.EmployeeId && actual.ProjectId == expected.ProjectId && actual.ProjectRoleId == expected.ProjectRoleId && actual.WorkLoad == expected.WorkLoad); projectWorkService.DeleteProjectWorkById(actual.Id); employeeService.DeleteEmployeeById(em1.Id); projectService.DeleteProjectById(pr1.Id); }
public void ChangeWorkLoad() { EmployeeService employeeService = new EmployeeService(uow, new Map <Employee, EmployeeDTO>()); ProjectService projectService = new ProjectService(uow, new Map <Project, ProjectDTO>()); ProjectWorkService projectWorkService = new ProjectWorkService(uow, new Map <ProjectWork, ProjectWorkDTO>()); EmployeeDTO employee = new EmployeeDTO { EmployeeName = "Екатерина", EmployeeSurname = "Антонович", EmployeePatronymic = "Алексеевна", RoleId = 3, Email = "*****@*****.**", }; var employeeOnWork = employeeService.CreateEmployee(employee); var em = employeeService.GetEmployeeById(employeeOnWork.Id); ProjectDTO project = new ProjectDTO { ProjectName = "проект 1", ProjectDescription = "проект номер один", ProjectStartDate = new DateTimeOffset(2021, 10, 6, 10, 15, 35, new TimeSpan(3, 0, 0)), ProjectEndDate = new DateTimeOffset(2021, 10, 21, 10, 15, 35, new TimeSpan(3, 0, 0)) }; var proj = projectService.CreateProject(project); var pr = projectService.GetProjectById(proj.Id); ProjectWorkDTO projectWork = new ProjectWorkDTO { EmployeeId = em.Id, ProjectId = pr.Id, ProjectRoleId = 3 }; var pWork = projectWorkService.CreateProjectWork(projectWork); var pw = projectWorkService.GetProjectWorkById(pWork.Id); projectWorkService.AddWorkLoad(pw.Id, 30); var pw1 = projectWorkService.GetProjectWorkById(pw.Id); projectWorkService.DeleteWorkLoad(pw1.Id); var pw2 = projectWorkService.GetProjectWorkById(pw1.Id); employeeService.ChangeWorkLoad(em.Id, 2); var actual = employeeService.GetEmployeeById(em.Id); EmployeeDTO expected = new EmployeeDTO { Id = em.Id, EmployeeName = "Екатерина", EmployeeSurname = "Антонович", EmployeePatronymic = "Алексеевна", RoleId = 3, Email = "*****@*****.**", PercentOrScheduleId = 2 }; Assert.IsTrue(actual.Id == expected.Id && actual.EmployeeName == expected.EmployeeName && actual.EmployeeSurname == expected.EmployeeSurname && actual.EmployeePatronymic == expected.EmployeePatronymic && actual.RoleId == expected.RoleId && actual.Email == expected.Email && actual.PercentOrScheduleId == expected.PercentOrScheduleId); projectWorkService.DeleteProjectWorkById(pw2.Id); employeeService.DeleteEmployeeById(em.Id); projectService.DeleteProjectById(pr.Id); }