public void Given_employee_When_amend_Then_should_set_properties_correctly() { //Given var employee = new Employee { ContactDetails = new List<EmployeeContactDetail> { new EmployeeContactDetail() } }; var amendParameters = new AddUpdateEmployeeParameters() { EmployeeReference = "Test" }; var contactDetails = new AddUpdateEmployeeContactDetailsParameters() { Address1 = "Address1", Address2 = "Address2", Address3 = "Address3" }; //When employee.Update(amendParameters, contactDetails, _user); //Then Assert.That(employee.EmployeeReference, Is.EqualTo(amendParameters.EmployeeReference)); Assert.That(employee.LastModifiedOn.Value.Date, Is.EqualTo(DateTime.Today)); Assert.That(employee.ContactDetails.Count, Is.EqualTo(1)); Assert.That(employee.ContactDetails.First().Address1, Is.EqualTo(contactDetails.Address1)); Assert.That(employee.ContactDetails.First().Address2, Is.EqualTo(contactDetails.Address2)); Assert.That(employee.ContactDetails.First().Address3, Is.EqualTo(contactDetails.Address3)); }
public AddUpdateEmployeeContactDetailsParameters Map(SaveEmployeeRequest request) { var result = new AddUpdateEmployeeContactDetailsParameters { Id = request.ContactDetailId, Address1 = request.Address1, Address2 = request.Address2, Address3 = request.Address3, Town = request.Town, County = request.County, PostCode = request.Postcode, Telephone1 = request.Telephone, Telephone2 = request.Mobile, Email = request.Email }; if (request.CountryId != default(int)) { result.Country = _countriesRepository.LoadById(request.CountryId); } return result; }
public void UpdateOnlineRegistrationDetails(UpdateOnlineRegistrationDetailsRequest request) { var employee = _employeeRepository.GetByIdAndCompanyId(request.EmployeeId, request.CompanyId); var currentUser = _userForAuditingRepository.GetByIdAndCompanyId(request.CurrentUserId, request.CompanyId); var employeeContactDetails = new AddUpdateEmployeeContactDetailsParameters() { Id = employee.ContactDetails.Any() ? employee.ContactDetails.Last().Id : 1, Email = request.Email, Telephone1 = request.Telephone, Telephone2 = request.Mobile }; employee.UpdateContactDetails(employeeContactDetails, currentUser); _employeeRepository.SaveOrUpdate(employee); }
public void Given_has_contact_detail_found_When_UpdateContactDetails_Then_calls_correct_method() { // Given var contactDetailsParameters = new AddUpdateEmployeeContactDetailsParameters { Id = 1L }; var userForAuditing = new UserForAuditing(); var target = new Employee(); var employeeContactDetail = new Mock<EmployeeContactDetail>(); employeeContactDetail .Setup(x => x.Id) .Returns(1L); employeeContactDetail .Setup(x => x.Update(contactDetailsParameters, userForAuditing, target)); target.ContactDetails.Add(employeeContactDetail.Object); // When target.UpdateContactDetails(contactDetailsParameters, userForAuditing); // Then employeeContactDetail.Verify(x => x.Update(contactDetailsParameters, userForAuditing, target)); }