public void Given_valid_request_When_reinstate_employee_as_not_deleted_Then_should_call_correct_methods() { // Given var request = new ReinstateEmployeeAsNotDeleteRequest() { CompanyId = 1, EmployeeId = Guid.NewGuid(), UserId = Guid.NewGuid() }; var target = CreateEmployeeService(); var employee = new Mock<Employee>(); _employeeRepository .Setup(x => x.GetByIdAndCompanyId(request.EmployeeId, request.CompanyId)) .Returns(employee.Object); _userRepository.Setup(x => x.GetByIdAndCompanyId(request.UserId, request.CompanyId)).Returns(new UserForAuditing() { Id = request.UserId }); // When target.ReinstateEmployeeAsNotDeleted(request); // Then _employeeRepository.Verify(x => x.SaveOrUpdate(It.IsAny<Employee>())); employee.Verify(x => x.ReinstateEmployeeAsNotDeleted(It.Is<UserForAuditing>(y => y.Id == request.UserId))); }
public void ReinstateEmployeeAsNotDeleted(ReinstateEmployeeAsNotDeleteRequest request) { _log.Add(request); try { var employee = _employeeRepository.GetByIdAndCompanyId(request.EmployeeId, request.CompanyId); var user = _userForAuditingRepository.GetByIdAndCompanyId(request.UserId, request.CompanyId); employee.ReinstateEmployeeAsNotDeleted(user); _employeeRepository.SaveOrUpdate(employee); } catch (Exception ex) { _log.Add(ex); throw; } }