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 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 CreateProjectWorkIfItsAlreadyExistsTest()
        {
            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 errors = pwvalidator.Validate(projectWork);
            var pWork  = projectWorkService.CreateProjectWork(projectWork);
            var actual = projectWorkService.GetProjectWorkById(pWork.Id);

            Assert.ThrowsException <ObjectAlreadyExistsException>(() => projectWorkService.CreateProjectWork(projectWork));

            projectWorkService.DeleteProjectWorkById(actual.Id);
            employeeService.DeleteEmployeeById(em.Id);
            projectService.DeleteProjectById(pr.Id);
        }
Exemple #4
0
        public void ChangeHistoryEndDateIfItsNotValidTest()
        {
            ParticipationHistoryService participationHistoryService = new ParticipationHistoryService(uow, new Map <ParticipationHistory, ParticipationHistoryDTO>());
            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, 11, 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);

            ParticipationHistoryDTO participationHistory = new ParticipationHistoryDTO
            {
                ProjectWorkId = prw.Id,
                StartDate     = new DateTimeOffset(2021, 10, 16, 10, 15, 35, new TimeSpan(3, 0, 0)),
                EndDate       = new DateTimeOffset(2021, 11, 21, 11, 15, 35, new TimeSpan(3, 0, 0))
            };

            var errors  = phvalidator.Validate(participationHistory);
            var history = participationHistoryService.CreateHistory(participationHistory);
            var actual  = participationHistoryService.GetHistoryById(history.Id);

            Assert.ThrowsException <InvalidDateException>(() => participationHistoryService.ChangeHistoryEndDate(actual.Id, new DateTimeOffset(2021, 9, 05, 10, 15, 35, new TimeSpan(3, 0, 0))));

            participationHistoryService.DeleteHistoryById(actual.Id);
            projectWorkService.DeleteProjectWorkById(prw.Id);
            employeeService.DeleteEmployeeById(em.Id);
            projectService.DeleteProjectById(pr.Id);
        }
        public void CreateScheduleIfEmployeeHasWorkloadTest()
        {
            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);

            projectWorkService.AddWorkLoad(prw.Id, 80);

            ScheduleDTO schedule = new ScheduleDTO
            {
                ProjectWorkId = prw.Id,
                ScheduleDayId = 1
            };

            Assert.ThrowsException <PercentOrScheduleException>(() => scheduleServise.CreateSchedule(schedule));

            projectWorkService.DeleteProjectWorkById(prw.Id);
            employeeService.DeleteEmployeeById(em.Id);
            projectService.DeleteProjectById(pr.Id);
        }
Exemple #6
0
        public void ChangeWorkLoadIfItsPercent()
        {
            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 actual = projectWorkService.GetProjectWorkById(pw.Id);

            Assert.ThrowsException <PercentOrScheduleException>(() => employeeService.ChangeWorkLoad(em.Id, 2));

            projectWorkService.DeleteProjectWorkById(actual.Id);
            employeeService.DeleteEmployeeById(em.Id);
            projectService.DeleteProjectById(pr.Id);
        }
Exemple #7
0
        public void GetLastEmployeesHistoryTest()
        {
            ParticipationHistoryService participationHistoryService = new ParticipationHistoryService(uow, new Map <ParticipationHistory, ParticipationHistoryDTO>());
            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, 11, 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);

            ParticipationHistoryDTO participationHistory1 = new ParticipationHistoryDTO
            {
                ProjectWorkId = prw.Id,
                StartDate     = new DateTimeOffset(2021, 10, 16, 10, 15, 35, new TimeSpan(3, 0, 0)),
                EndDate       = new DateTimeOffset(2021, 11, 04, 11, 15, 35, new TimeSpan(3, 0, 0))
            };
            var errors   = phvalidator.Validate(participationHistory1);
            var history1 = participationHistoryService.CreateHistory(participationHistory1);
            var actual1  = participationHistoryService.GetHistoryById(history1.Id);

            ParticipationHistoryDTO participationHistory2 = new ParticipationHistoryDTO
            {
                ProjectWorkId = prw.Id,
                StartDate     = new DateTimeOffset(2021, 11, 05, 10, 15, 35, new TimeSpan(3, 0, 0)),
                EndDate       = new DateTimeOffset(2021, 11, 21, 11, 15, 35, new TimeSpan(3, 0, 0))
            };
            var errors2  = phvalidator.Validate(participationHistory2);
            var history2 = participationHistoryService.CreateHistory(participationHistory2);
            var actual2  = participationHistoryService.GetHistoryById(history2.Id);

            var actual = participationHistoryService.GetLastEmployeesHistory(prw.Id);
            ParticipationHistoryDTO expected = new ParticipationHistoryDTO
            {
                Id            = actual2.Id,
                ProjectWorkId = prw.Id,
                StartDate     = new DateTimeOffset(2021, 11, 05, 10, 15, 35, new TimeSpan(3, 0, 0)),
                EndDate       = new DateTimeOffset(2021, 11, 21, 11, 15, 35, new TimeSpan(3, 0, 0))
            };

            Assert.IsTrue(errors.Count == 0 && errors2.Count == 0 && actual.Id == expected.Id && actual.ProjectWorkId == expected.ProjectWorkId &&
                          actual.StartDate == expected.StartDate && actual.EndDate == expected.EndDate);

            participationHistoryService.DeleteHistoryById(actual1.Id);
            participationHistoryService.DeleteHistoryById(actual2.Id);
            projectWorkService.DeleteProjectWorkById(prw.Id);
            employeeService.DeleteEmployeeById(em.Id);
            projectService.DeleteProjectById(pr.Id);
        }
Exemple #8
0
        public void GetAllEmployeesHistoriesOnProjectTest()
        {
            ParticipationHistoryService participationHistoryService = new ParticipationHistoryService(uow, new Map <ParticipationHistory, ParticipationHistoryDTO>());
            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);

            EmployeeDTO employee2 = new EmployeeDTO
            {
                EmployeeName       = "Иван",
                EmployeeSurname    = "Иванов",
                EmployeePatronymic = "Иванович",
                RoleId             = 2,
                Email = "*****@*****.**",
            };
            var employeeOnWork2 = employeeService.CreateEmployee(employee2);
            var em2             = employeeService.GetEmployeeById(employeeOnWork2.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, 11, 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);

            ProjectWorkDTO projectWork2 = new ProjectWorkDTO
            {
                EmployeeId    = em2.Id,
                ProjectId     = pr.Id,
                ProjectRoleId = 2
            };
            var pWork2 = projectWorkService.CreateProjectWork(projectWork2);
            var prw2   = projectWorkService.GetProjectWorkById(pWork2.Id);

            ParticipationHistoryDTO participationHistory1 = new ParticipationHistoryDTO
            {
                ProjectWorkId = prw.Id,
                StartDate     = new DateTimeOffset(2021, 10, 16, 10, 15, 35, new TimeSpan(3, 0, 0)),
                EndDate       = new DateTimeOffset(2021, 11, 04, 11, 15, 35, new TimeSpan(3, 0, 0))
            };
            var errors   = phvalidator.Validate(participationHistory1);
            var history1 = participationHistoryService.CreateHistory(participationHistory1);
            var actual1  = participationHistoryService.GetHistoryById(history1.Id);

            ParticipationHistoryDTO participationHistory2 = new ParticipationHistoryDTO
            {
                ProjectWorkId = prw.Id,
                StartDate     = new DateTimeOffset(2021, 11, 05, 10, 15, 35, new TimeSpan(3, 0, 0)),
                EndDate       = new DateTimeOffset(2021, 11, 21, 11, 15, 35, new TimeSpan(3, 0, 0))
            };
            var errors2  = phvalidator.Validate(participationHistory2);
            var history2 = participationHistoryService.CreateHistory(participationHistory2);
            var actual2  = participationHistoryService.GetHistoryById(history2.Id);

            ParticipationHistoryDTO participationHistory3 = new ParticipationHistoryDTO
            {
                ProjectWorkId = prw2.Id,
                StartDate     = new DateTimeOffset(2021, 11, 05, 10, 15, 35, new TimeSpan(3, 0, 0)),
                EndDate       = new DateTimeOffset(2021, 11, 21, 11, 15, 35, new TimeSpan(3, 0, 0))
            };
            var errors3  = phvalidator.Validate(participationHistory3);
            var history3 = participationHistoryService.CreateHistory(participationHistory3);
            var actual3  = participationHistoryService.GetHistoryById(history3.Id);

            var actual = participationHistoryService.GetAllEmployeesHistoriesOnProject(prw.Id).ToList();

            Assert.AreEqual(actual.Count, 2);

            participationHistoryService.DeleteHistoryById(actual1.Id);
            participationHistoryService.DeleteHistoryById(actual2.Id);
            participationHistoryService.DeleteHistoryById(actual3.Id);
            projectWorkService.DeleteProjectWorkById(prw.Id);
            projectWorkService.DeleteProjectWorkById(prw2.Id);
            employeeService.DeleteEmployeeById(em.Id);
            employeeService.DeleteEmployeeById(em2.Id);
            projectService.DeleteProjectById(pr.Id);
        }
        public void DeleteEmployeeFromProjectTest()
        {
            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);

            EmployeeDTO employee2 = new EmployeeDTO
            {
                EmployeeName       = "Иван",
                EmployeeSurname    = "Иванов",
                EmployeePatronymic = "Иванович",
                RoleId             = 3,
                Email = "*****@*****.**",
            };
            var employeeOnWork2 = employeeService.CreateEmployee(employee2);
            var em2             = employeeService.GetEmployeeById(employeeOnWork2.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 projectWork1 = new ProjectWorkDTO
            {
                EmployeeId    = em1.Id,
                ProjectId     = pr.Id,
                ProjectRoleId = 3
            };
            var errors1 = pwvalidator.Validate(projectWork1);
            var pWork1  = projectWorkService.CreateProjectWork(projectWork1);
            var actual1 = projectWorkService.GetProjectWorkById(pWork1.Id);

            ProjectWorkDTO projectWork2 = new ProjectWorkDTO
            {
                EmployeeId    = em2.Id,
                ProjectId     = pr.Id,
                ProjectRoleId = 5
            };
            var errors2 = pwvalidator.Validate(projectWork2);
            var pWork2  = projectWorkService.CreateProjectWork(projectWork2);
            var actual2 = projectWorkService.GetProjectWorkById(pWork2.Id);

            projectWorkService.DeleteEmployeeFromProject(pr.Id, em1.Id);
            var result = projectWorkService.GetNamesOnProject(pr.Id).ToList();

            Assert.AreEqual(result.Count, 1);

            projectWorkService.DeleteProjectWorkById(actual2.Id);
            employeeService.DeleteEmployeeById(em1.Id);
            employeeService.DeleteEmployeeById(em2.Id);
            projectService.DeleteProjectById(pr.Id);
        }
        public void GetNamesOnProjectTest()
        {
            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        employee1          = new EmployeeDTO
            {
                EmployeeName       = "Екатерина",
                EmployeeSurname    = "Антонович",
                EmployeePatronymic = "Алексеевна",
                RoleId             = 3,
                Email = "*****@*****.**",
            };
            var employeeOnWork1 = employeeService.CreateEmployee(employee1);
            var em1             = employeeService.GetEmployeeById(employeeOnWork1.Id);

            EmployeeDTO employee2 = new EmployeeDTO
            {
                EmployeeName       = "Иван",
                EmployeeSurname    = "Иванов",
                EmployeePatronymic = "Иванович",
                RoleId             = 3,
                Email = "*****@*****.**",
            };
            var employeeOnWork2 = employeeService.CreateEmployee(employee2);
            var em2             = employeeService.GetEmployeeById(employeeOnWork2.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 projectWork1 = new ProjectWorkDTO
            {
                EmployeeId    = em1.Id,
                ProjectId     = pr.Id,
                ProjectRoleId = 3
            };
            var errors1 = pwvalidator.Validate(projectWork1);
            var pWork1  = projectWorkService.CreateProjectWork(projectWork1);
            var actual1 = projectWorkService.GetProjectWorkById(pWork1.Id);

            projectWorkService.AddWorkLoad(actual1.Id, 50);

            ProjectWorkDTO projectWork2 = new ProjectWorkDTO
            {
                EmployeeId    = em2.Id,
                ProjectId     = pr.Id,
                ProjectRoleId = 5
            };
            var errors2 = pwvalidator.Validate(projectWork2);
            var pWork2  = projectWorkService.CreateProjectWork(projectWork2);
            var actual2 = projectWorkService.GetProjectWorkById(pWork2.Id);

            scheduleServise.CreateSchedule(new ScheduleDTO {
                ProjectWorkId = actual2.Id, ScheduleDayId = 2
            });
            scheduleServise.CreateSchedule(new ScheduleDTO {
                ProjectWorkId = actual2.Id, ScheduleDayId = 4
            });

            var result = projectWorkService.GetNamesOnProject(pr.Id).ToList();

            Assert.IsTrue(result.First().name == "Антонович Екатерина Алексеевна" && result.Last().name == "Иванов Иван Иванович");

            projectWorkService.DeleteProjectWorkById(actual1.Id);
            projectWorkService.DeleteProjectWorkById(actual2.Id);
            employeeService.DeleteEmployeeById(em1.Id);
            employeeService.DeleteEmployeeById(em2.Id);
            projectService.DeleteProjectById(pr.Id);
        }
        public void CalculateEmployeesWorkloadTest()
        {
            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);

            ProjectDTO project2 = new ProjectDTO
            {
                ProjectName        = "проект 2",
                ProjectDescription = "проект номер два",
                ProjectStartDate   = new DateTimeOffset(2021, 2, 14, 10, 15, 35, new TimeSpan(3, 0, 0)),
                ProjectEndDate     = new DateTimeOffset(2021, 8, 21, 10, 15, 35, new TimeSpan(3, 0, 0))
            };
            var proj2 = projectService.CreateProject(project2);
            var pr2   = projectService.GetProjectById(proj2.Id);

            ProjectWorkDTO projectWork1 = new ProjectWorkDTO
            {
                EmployeeId    = em1.Id,
                ProjectId     = pr1.Id,
                ProjectRoleId = 3
            };
            var errors1 = pwvalidator.Validate(projectWork1);
            var pWork1  = projectWorkService.CreateProjectWork(projectWork1);
            var actual1 = projectWorkService.GetProjectWorkById(pWork1.Id);

            projectWorkService.AddWorkLoad(actual1.Id, 20);

            ProjectWorkDTO projectWork2 = new ProjectWorkDTO
            {
                EmployeeId    = em1.Id,
                ProjectId     = pr2.Id,
                ProjectRoleId = 5
            };
            var errors2 = pwvalidator.Validate(projectWork2);
            var pWork2  = projectWorkService.CreateProjectWork(projectWork2);
            var actual2 = projectWorkService.GetProjectWorkById(pWork2.Id);

            projectWorkService.AddWorkLoad(actual2.Id, 50);

            var result = projectWorkService.CalculateEmployeesWorkload(em1.Id);

            Assert.AreEqual(result, 70);

            projectWorkService.DeleteProjectWorkById(actual1.Id);
            projectWorkService.DeleteProjectWorkById(actual2.Id);
            employeeService.DeleteEmployeeById(em1.Id);
            projectService.DeleteProjectById(pr1.Id);
            projectService.DeleteProjectById(pr2.Id);
        }