public void CreateScheduleTest() { ScheduleServise scheduleServise = new ScheduleServise(uow, new Map <Schedule, ScheduleDTO>(), new Map <ScheduleDay, ScheduleDayDTO>()); 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 prw = projectWorkService.GetProjectWorkById(pWork.Id); ScheduleDTO schedule = new ScheduleDTO { ProjectWorkId = prw.Id, ScheduleDayId = 1 }; var sch = scheduleServise.CreateSchedule(schedule); ScheduleDTO actual = scheduleServise.GetScheduleById(sch.Id); ScheduleDTO expected = new ScheduleDTO { Id = actual.Id, ProjectWorkId = prw.Id, ScheduleDayId = 1 }; Assert.IsTrue(actual.Id == expected.Id && actual.ProjectWorkId == expected.ProjectWorkId && actual.ScheduleDayId == expected.ScheduleDayId); scheduleServise.DeleteScheduleById(actual.Id); projectWorkService.DeleteProjectWorkById(prw.Id); employeeService.DeleteEmployeeById(em.Id); projectService.DeleteProjectById(pr.Id); }
public void DeleteScheduleByProjectWorkIdTest() { ScheduleServise scheduleServise = new ScheduleServise(uow, new Map <Schedule, ScheduleDTO>(), new Map <ScheduleDay, ScheduleDayDTO>()); 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 prw = projectWorkService.GetProjectWorkById(pWork.Id); ScheduleDTO schedule1 = new ScheduleDTO { ProjectWorkId = prw.Id, ScheduleDayId = 1 }; var sch1 = scheduleServise.CreateSchedule(schedule1); ScheduleDTO actual1 = scheduleServise.GetScheduleById(sch1.Id); ScheduleDTO schedule2 = new ScheduleDTO { ProjectWorkId = prw.Id, ScheduleDayId = 3 }; var sch2 = scheduleServise.CreateSchedule(schedule2); ScheduleDTO actual2 = scheduleServise.GetScheduleById(sch2.Id); scheduleServise.DeleteScheduleByProjectWorkId(prw.Id); Assert.ThrowsException <NotFoundException>(() => scheduleServise.GetScheduleOnProjectWork(prw.Id)); projectWorkService.DeleteProjectWorkById(prw.Id); employeeService.DeleteEmployeeById(em.Id); projectService.DeleteProjectById(pr.Id); }