public void Given_valid_request_When_DetachEmployee_is_called_Then_should_call_appropiate_methods()
        {
            //Given
            var riskAssessmentService = CreateRiskAssessmentService();
            var detachEmployeeRequest = new DetachEmployeeRequest
                                            {
                                                                     EmployeeIds = new List<Guid> { Guid.NewGuid() },
                                                                     RiskAssessmentId = 2
                                                                 };

            var mockRiskAssessment = new Mock<GeneralRiskAssessment>();
            _riskAssessmentRepository
                .Setup(rr => rr.GetByIdAndCompanyId(detachEmployeeRequest.RiskAssessmentId, detachEmployeeRequest.CompanyId))
                .Returns(mockRiskAssessment.Object);

            var employees = new[]{ new Employee()};
            _employeeRepository.Setup(x => x.GetByIds(detachEmployeeRequest.EmployeeIds)).Returns(employees);

            SetupValidUser(detachEmployeeRequest);

           
            //When
            riskAssessmentService.DetachEmployeeFromRiskAssessment(detachEmployeeRequest);

            //Then
            _riskAssessmentRepository.VerifyAll();
            mockRiskAssessment.Verify(x => x.DetachEmployeesFromRiskAssessment(employees, _user));
        }
 private void SetupValidUser(DetachEmployeeRequest detachEmployeeRequest)
 {
     _userRepository.Setup(x => x.GetByIdAndCompanyId(detachEmployeeRequest.UserId,detachEmployeeRequest.CompanyId)).Returns(_user);
 }
        public void DetachEmployeeFromRiskAssessment(DetachEmployeeRequest request)
        {
            _log.Add(request);

            try
            {
                var user = _userForAuditingRepository.GetByIdAndCompanyId(request.UserId, request.CompanyId);
                var riskAssessment = _riskAssessmentRepository.GetByIdAndCompanyId(request.RiskAssessmentId, request.CompanyId);
                var employees = _employeeRepository.GetByIds(request.EmployeeIds);

                riskAssessment.DetachEmployeesFromRiskAssessment(employees, user);

                _riskAssessmentRepository.SaveOrUpdate(riskAssessment);
            }
            catch (Exception ex)
            {
                _log.Add(ex);
                throw;
            }

        }