public void Given_all_required_fields_are_available_Then_create_user_method_creates_an_object() { //Given Guid userId = Guid.NewGuid(); const long companyId = 33749; const long siteId = 324234L; var role = new Role() { Id = new Guid("BACF7C01-D210-4DBC-942F-15D8456D3B92") }; var user = new UserForAuditing() { Id = new Guid("B03C83EE-39F2-4F88-B4C4-7C276B1AAD99") }; var site = new Site() {Id = siteId}; var employeeContactDetail = new EmployeeContactDetail {Email = "*****@*****.**"}; var employee = new Employee {Forename = "Gary", Surname = "Green",ContactDetails = new List<EmployeeContactDetail> {employeeContactDetail}}; //When var result = User.CreateUser(userId, companyId, role, site, employee, user); //Then Assert.That(result.Id, Is.EqualTo(userId)); Assert.That(result.CompanyId, Is.EqualTo(companyId)); Assert.That(result.Site.Id, Is.EqualTo(siteId)); Assert.That(result.Employee, Is.Not.Null); Assert.That(result.Employee.Forename, Is.EqualTo("Gary")); Assert.That(result.Employee.Surname, Is.EqualTo("Green")); Assert.That(result.Employee.ContactDetails, Is.Not.Null); Assert.That(result.Employee.ContactDetails.Count, Is.EqualTo(1)); Assert.That(result.Employee.ContactDetails[0].Email, Is.EqualTo("*****@*****.**")); }
public void Given_contact_details_when_mapped_then_properties_are_mapped_correctly() { //given var contactDetails = new EmployeeContactDetail(); contactDetails.Id = 23531245L; contactDetails.Address1 = "entity.Address1"; contactDetails.Address2 = "entity.Address2,"; contactDetails.Address3 = "entity.Address3"; contactDetails.Town = "entity.Town,"; contactDetails.County = "entity.County,"; contactDetails.PostCode = "entity.PostCode,"; contactDetails.Telephone1 = "entity.Telephone1,"; contactDetails.Telephone2 = "entity.Telephone2,"; contactDetails.PreferedTelephone = 431; contactDetails.Email = "entity.Email,"; // Country = entity.Country != null ? new CountryDtoMapper().Map(entity //when var result = new EmployeeContactDetailDtoMapper().MapWithCountry(contactDetails); //then Assert.That(result.Id, Is.EqualTo(contactDetails.Id)); Assert.That(result.Address1, Is.EqualTo(contactDetails.Address1)); Assert.That(result.Address2, Is.EqualTo(contactDetails.Address2)); Assert.That(result.Address3, Is.EqualTo(contactDetails.Address3)); Assert.That(result.Town, Is.EqualTo(contactDetails.Town)); Assert.That(result.County, Is.EqualTo(contactDetails.County)); Assert.That(result.PostCode, Is.EqualTo(contactDetails.PostCode)); Assert.That(result.Telephone1, Is.EqualTo(contactDetails.Telephone1)); Assert.That(result.Telephone2, Is.EqualTo(contactDetails.Telephone2)); Assert.That(result.PreferedTelephone, Is.EqualTo(contactDetails.PreferedTelephone)); Assert.That(result.Email, Is.EqualTo(contactDetails.Email)); }
public void Given_ra_is_general_When_RiskAssessmentReview_Create_is_called_Then_correct_methods_are_called_RiskAssessmentReview_is_correct_and_Task_is_also_created() { //Given const long companyId = 300L; var employeeContactDetail = new EmployeeContactDetail { Email = "*****@*****.**" }; var employee = new Employee { Forename = "Gary", Surname = "Green", ContactDetails = new List<EmployeeContactDetail> { employeeContactDetail } }; var user = new UserForAuditing { Id = Guid.NewGuid() }; var completionDueDate = DateTime.Now.AddDays(10); var employeeToAssignTo = Employee.Create(new AddUpdateEmployeeParameters { ClientId = companyId, Forename = "Brian", Surname = "Beige" }, user); var riskAssessment = GeneralRiskAssessment.Create("Risk Assessment 01", "RA01", companyId, user); var taskCategory = TaskCategory.Create(3, "Test GRA Review"); _responsibilityTaskCategoryRepository .Setup(x => x.GetGeneralRiskAssessmentTaskCategory()) .Returns(taskCategory); //When var riskAssessmentReview = RiskAssessmentReviewFactory.Create( riskAssessment, user, employeeToAssignTo, completionDueDate, _responsibilityTaskCategoryRepository.Object, false, false, false, false, Guid.NewGuid()); //Then _responsibilityTaskCategoryRepository.VerifyAll(); Assert.That(riskAssessmentReview.RiskAssessment, Is.SameAs(riskAssessment)); Assert.That(riskAssessmentReview.ReviewAssignedTo, Is.SameAs(employeeToAssignTo)); Assert.That(riskAssessmentReview.CreatedBy, Is.SameAs(user)); Assert.That(riskAssessmentReview.CompletionDueDate, Is.EqualTo((completionDueDate))); Assert.That(riskAssessment.Reviews.Count(), Is.EqualTo(1)); Assert.That(riskAssessment.Reviews.Contains(riskAssessmentReview)); var task = riskAssessmentReview.RiskAssessmentReviewTask; Assert.That(task, Is.Not.Null); Assert.That(task.Reference, Is.EqualTo(riskAssessment.Reference)); Assert.That(task.Title, Is.EqualTo(riskAssessment.Title)); Assert.That(task.Description, Is.EqualTo("GRA Review")); Assert.That(task.TaskCompletionDueDate, Is.EqualTo(completionDueDate)); Assert.That(task.TaskStatus, Is.EqualTo(TaskStatus.Outstanding)); Assert.That(task.TaskAssignedTo, Is.EqualTo(riskAssessmentReview.ReviewAssignedTo)); Assert.That(task.TaskReoccurringType, Is.EqualTo(TaskReoccurringType.None)); Assert.That(task.Category, Is.SameAs(taskCategory)); }
public void Given_employee_already_exists_Then_should_get_correct_exception() { //Given //Given var employee = new Employee(); var contactDetails = new EmployeeContactDetail(); employee.AddContactDetails(contactDetails); //When //Then Assert.Throws<ContactDetailsAlreadyAttachedToEmployeeException>(() => employee.AddContactDetails(contactDetails)); }
public void Given_employee_When_add_contact_details_Then_should_attach_as_appropiate() { //Given var employee = new Employee(); var contactDetails = new EmployeeContactDetail(); //When employee.AddContactDetails(contactDetails); //Then Assert.That(employee.ContactDetails.Count, Is.EqualTo(1)); }
public void Given_all_required_fields_are_available_When_Set_role_and_sites_is_called_Then_create_user_method_creates_an_object() { //Given long companyId = 999L; var oldRole = new Role { Id = Guid.NewGuid(), CompanyId = companyId }; var newRole = new Role { Id = Guid.NewGuid(), CompanyId = companyId }; var user = new UserForAuditing { Id = new Guid("B03C83EE-39F2-4F88-B4C4-7C276B1AAD99"), CompanyId = companyId }; var employeeContactDetail = new EmployeeContactDetail { Email = "*****@*****.**" }; var employee = new Employee { Forename = "Gary", Surname = "Green", ContactDetails = new List<EmployeeContactDetail> { employeeContactDetail } }; var userToUpdate = User.CreateUser(Guid.NewGuid(), companyId, oldRole, null, employee, user); var actioningUser = new UserForAuditing() { Id= Guid.NewGuid(), CompanyId = companyId }; var site = new Site { Id = 1, ClientId = companyId }; //When userToUpdate.SetRoleAndSite(newRole, site, actioningUser); //Then Assert.AreEqual(newRole, userToUpdate.Role); Assert.AreEqual(site, userToUpdate.Site); Assert.AreEqual(actioningUser, userToUpdate.LastModifiedBy); }
public EmployeeContactDetailDto MapWithCountry(EmployeeContactDetail entity) { return new EmployeeContactDetailDto { Id = entity.Id, Address1 = entity.Address1, Address2 = entity.Address2, Address3 = entity.Address3, Town = entity.Town, County = entity.County, PostCode = entity.PostCode, Telephone1 = entity.Telephone1, Telephone2 = entity.Telephone2, PreferedTelephone = entity.PreferedTelephone, Email = entity.Email, Country = entity.Country != null ? new CountryDtoMapper().Map(entity.Country) : null }; }
public void Given_archive_is_false_When_complete_is_called_Then_follow_up_should_be_created() { //Given const long companyId = 300L; var completionDueDate = DateTime.Now.AddDays(10); var nextReviewDate = DateTime.Now.AddDays(30); var employeeContactDetail = new EmployeeContactDetail { Email = "*****@*****.**" }; var employee = new Employee { Forename = "Gary", Surname = "Green", ContactDetails = new List<EmployeeContactDetail> { employeeContactDetail } }; var user = User.CreateUser(Guid.NewGuid(), companyId, null, null, employee, null); var userForAuditing = new UserForAuditing() { Id = user.Id }; var employeeToAssignTo = Employee.Create(new AddUpdateEmployeeParameters { ClientId = companyId, Forename = "Brian", Surname = "Beige" }, userForAuditing); user.Employee = employeeToAssignTo; var riskAssessment = GeneralRiskAssessment.Create("Risk Assessment 01", "RA01", companyId, userForAuditing); var taskCategory = TaskCategory.Create(3, "Test GRA Review"); _responsibilityTaskCategoryRepository .Setup(x => x.GetGeneralRiskAssessmentTaskCategory()) .Returns(taskCategory); var riskAssessmentReview = RiskAssessmentReviewFactory.Create( riskAssessment, userForAuditing, employeeToAssignTo, completionDueDate, _responsibilityTaskCategoryRepository.Object, false, false, false, false, Guid.NewGuid()); //When riskAssessmentReview.Complete("Test Completion", userForAuditing, nextReviewDate, false, new List<CreateDocumentParameters>(), user); //Then Assert.That(riskAssessment.Reviews.Count(), Is.EqualTo(2)); var newReview = riskAssessment.Reviews[1]; Assert.That(newReview.RiskAssessment, Is.SameAs(riskAssessment)); Assert.That(newReview.ReviewAssignedTo, Is.SameAs(employeeToAssignTo)); Assert.That(newReview.CreatedBy, Is.SameAs(userForAuditing)); Assert.That(newReview.CompletionDueDate, Is.EqualTo((nextReviewDate))); var task = newReview.RiskAssessmentReviewTask; Assert.That(task, Is.Not.Null); Assert.That(task.Reference, Is.EqualTo(riskAssessment.Reference)); Assert.That(task.Title, Is.EqualTo(riskAssessment.Title)); Assert.That(task.Description, Is.EqualTo("GRA Review")); Assert.That(task.TaskCompletionDueDate, Is.EqualTo(nextReviewDate)); Assert.That(task.TaskStatus, Is.EqualTo(TaskStatus.Outstanding)); Assert.That(task.TaskAssignedTo, Is.EqualTo(riskAssessmentReview.ReviewAssignedTo)); Assert.That(task.TaskReoccurringType, Is.EqualTo(TaskReoccurringType.None)); Assert.That(task.Category, Is.SameAs(taskCategory)); }
public ContactDetailsAlreadyAttachedToEmployeeException(Employee employee, EmployeeContactDetail contactDetails) : base(string.Format("Trying to attach contact details to employee. Employee Id {0}. Contact Details Id {1}", employee.Id, contactDetails.Id)) { }
public void Given_role_is_not_same_company_as_user_When_Set_role_and_sites_is_called_Then_correct_excpetion_is_thrown() { //Given long companyId = 999L; var oldRole = new Role { Id = Guid.NewGuid(), CompanyId = companyId }; var newRole = new Role { Id = Guid.NewGuid(), CompanyId = 333L }; var user = new UserForAuditing { Id = new Guid("B03C83EE-39F2-4F88-B4C4-7C276B1AAD99"), CompanyId = companyId }; var employeeContactDetail = new EmployeeContactDetail { Email = "*****@*****.**" }; var employee = new Employee { Forename = "Gary", Surname = "Green", ContactDetails = new List<EmployeeContactDetail> { employeeContactDetail } }; var userToUpdate = User.CreateUser(Guid.NewGuid(), companyId, oldRole, null, employee, user); var actioningUser = new UserForAuditing() { Id = Guid.NewGuid(), CompanyId = companyId }; //Todo: finish when sites are refactored. var site = new Site { Id = 1, ClientId = companyId }; //When userToUpdate.SetRoleAndSite(newRole, site, actioningUser); //Then exception is thrown. }
public bool Update(EmployeeContactDetail obj, string[] param, string spName) { return(_IContactRepository.Update(obj, param, spName)); }
public bool Insert(EmployeeContactDetail obj, string[] param, string spName) { return(_IContactRepository.Insert(obj, param, spName)); }
public IEnumerable <EmployeeContactDetail> GetAll(EmployeeContactDetail obj, string[] param, string spName) { return(_IContactRepository.GetAll(obj, param, spName)); }