public void SetUp() { _bus = new Mock<IBus>(); _accidentRecordRepository = new Mock<IAccidentRecordRepository>(); _siteRepository = new Mock<ISiteRepository>(); _userRepository = new Mock<IUserForAuditingRepository>(); _user = new UserForAuditing { Id = new Guid() }; _site = new Site(); _accidentRecord = new AccidentRecord() { Id = _accidentRecordId, CompanyId = _companyId, SiteWhereHappened = _site, DoNotSendEmailNotification = false, EmailNotificationSent = false }; _userRepository .Setup(curUserRepository => curUserRepository.GetByIdAndCompanyId(It.IsAny<Guid>(),It.IsAny<long>())) .Returns(_user); _accidentRecordRepository.Setup(x => x.GetByIdAndCompanyId(It.IsAny<long>(), It.IsAny<long>())) .Returns(_accidentRecord); var emp = new Employee(); emp.ContactDetails = new List<EmployeeContactDetail>(); emp.ContactDetails.Add(new EmployeeContactDetail() { Employee = emp, Email = "*****@*****.**" }); _site.AddAccidentRecordNotificationMember(emp, _user); _siteRepository.Setup(x => x.GetById(It.IsAny<long>())).Returns(_site); }
public void Given_all_required_felds_are_available_When_UpdatePremisesInformation_Then_Values_Updated() { //Given const string title = "RA Test"; const string personAppointed = "Person Appointed"; const string reference = "RA 001"; const long clientId = 100; var user = new UserForAuditing(); var riskAssessor = new RiskAssessor(); var dateOfAssessment = DateTime.Now; var site = new Site(); var result = FireRiskAssessment.Create(title, reference, clientId, new Checklist(), user); //When result.UpdateSummary("new title", "new ref", personAppointed, dateOfAssessment, riskAssessor, site, user); //Then Assert.That(result.Title, Is.EqualTo("new title")); Assert.That(result.PersonAppointed, Is.EqualTo(personAppointed)); Assert.That(result.Reference, Is.EqualTo("new ref")); Assert.That(result.AssessmentDate, Is.EqualTo(dateOfAssessment)); Assert.That(result.RiskAssessor, Is.EqualTo(riskAssessor)); Assert.That(result.RiskAssessmentSite, Is.EqualTo(site)); Assert.That(result.LastModifiedBy, Is.EqualTo(user)); Assert.That(result.LastModifiedOn.Value.Date, Is.EqualTo(DateTime.Today)); }
public static PersonalRiskAssessment Create( string title, string reference, long clientId, UserForAuditing currentUser, string location, string taskProcessDescription, Site site, DateTime? assessmentDate, RiskAssessor riskAssessor, bool IsSensitive ) { var riskAssessment = new PersonalRiskAssessment { Title = title, Reference = reference, AssessmentDate = assessmentDate, RiskAssessmentSite = site, RiskAssessor = riskAssessor, Location = location, TaskProcessDescription = taskProcessDescription, CompanyId = clientId, CreatedBy = currentUser, CreatedOn = DateTime.Now, Status = RiskAssessmentStatus.Draft, Sensitive = IsSensitive }; return riskAssessment; }
public void Setup() { _responsibilityRepo = new Mock<IResponsibilityRepository>(); _log = new Mock<IPeninsulaLog>(); _responsibility = new Mock<Responsibility>(); _site = new Site() {Id = 311}; _employee = new Employee() {Id = Guid.NewGuid()}; _userForAuditingRepository = new Mock<IUserForAuditingRepository>(); _userForAuditingRepository.Setup(x => x.GetByIdAndCompanyId(It.IsAny<Guid>(), It.IsAny<long>())) .Returns(new UserForAuditing() {Id = _user, CompanyId = _companyId}); _originalResponibility = new Responsibility() { CompanyId = _companyId, ResponsibilityCategory = ResponsibilityCategory.Create(1, "Category"), Title = "Title Orig", Description = "Description", Site = new Site() { Id = 1 }, ResponsibilityReason = new ResponsibilityReason() { Id = 1 }, Owner = _employee, InitialTaskReoccurringType = TaskReoccurringType.ThreeMonthly, ResponsibilityTasks = new List<ResponsibilityTask>() { new ResponsibilityTask() { Id = 1 }, new ResponsibilityTask() { Id = 2 }, new ResponsibilityTask() { Id = 3 } }, CreatedOn = _createdOn, StatutoryResponsibilityTemplateCreatedFrom = new StatutoryResponsibilityTemplate() { Id = 2 }, Id = _originalResponsibilityId }; }
public void Given_that_get_all_sites_is_called_and_one_site_is_closed_Then_should_return_correct_result() { //Given var target = CreateSiteService(); //Open Site var site1 = Site.Create(2, null, 1, "Aa", "Aa Aa", "", new UserForAuditing()); //closed site var site2 = Site.Create(1, null, 1, "Bo", "Bo Bo", "", new UserForAuditing()); site2.SiteClosedDate = DateTime.Now; var sites = new Site[] { site1, site2 }; _siteAddressRepository.Setup(x => x.GetSiteAddressByCompanyId(_companyId)).Returns(sites); //When var result = target.GetAll(_companyId); //Then Assert.That(result.Count(), Is.EqualTo(1)); Assert.That(result.First().Name, Is.EqualTo("Aa")); }
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 virtual void UpdateSummary(string title, string reference, DateTime? assessmentDate, RiskAssessor riskAssessor, Site site, UserForAuditing currentUser) { if (IsDifferentRiskAssessor(riskAssessor)) { if (AreThereAnyFurtherControlMeasureTasks()) { Hazards .Where(h => h.FurtherControlMeasureTasks != null) .SelectMany(h => h.FurtherControlMeasureTasks) .ToList() .ForEach(task => { task.SendTaskCompletedNotification = riskAssessor == null ? true : !riskAssessor.DoNotSendTaskCompletedNotifications; task.SendTaskOverdueNotification = riskAssessor == null ? true : !riskAssessor.DoNotSendTaskOverdueNotifications; task.SetLastModifiedDetails(currentUser); }); } } Title = title; Reference = reference; RiskAssessor = riskAssessor; AssessmentDate = assessmentDate; RiskAssessmentSite = site; SetLastModifiedDetails(currentUser); }
public static GeneralRiskAssessment Create( string title, string reference, long clientId, UserForAuditing currentUser, string location, string taskProcessDescription, Site site, DateTime? assessmentDate, RiskAssessor riskAssessor ) { var riskAssessment = new GeneralRiskAssessment { Title = title, Reference = reference, AssessmentDate = assessmentDate, RiskAssessmentSite = site, RiskAssessor = riskAssessor, Location = location, TaskProcessDescription = taskProcessDescription, CompanyId = clientId, CreatedBy = currentUser, CreatedOn = DateTime.Now, Status = RiskAssessmentStatus.Draft, PeopleAtRisk = new List<RiskAssessmentPeopleAtRisk>(), }; return riskAssessment; }
public void Given_valid_parameters_When_search_is_called_correct_parameters_are_called() { //Given var userId = Guid.NewGuid(); var companyId = 374L; var siteId = 243L; var site = new Site { Id = siteId, Name = "Test Site" }; _siteRepository .Setup(x => x.Search(companyId, null, new List<long>{ siteId }, null)) .Returns(new List<Site> { site }); //When CreateTarget().Search(new SearchSitesRequest { CompanyId = companyId, AllowedSiteIds = new List<long> {siteId}, }); //Then _siteRepository.VerifyAll(); }
public void Setup() { _site = new Site() { Id = 311 }; _employee = new Employee() { Id = Guid.NewGuid() }; _originalResponibility = new Responsibility() { CompanyId = _companyId, ResponsibilityCategory = ResponsibilityCategory.Create(1, "Category"), Title = "Title Orig", Description = "Description", Site = new Site() { Id = 1 }, ResponsibilityReason = new ResponsibilityReason() { Id = 1 }, Owner = _employee, InitialTaskReoccurringType = TaskReoccurringType.ThreeMonthly, ResponsibilityTasks = new List<ResponsibilityTask>() { new ResponsibilityTask() { Id = 1, Title = "1", Site = new Site() { Id = 1}, TaskAssignedTo = new Employee() { Id = Guid.NewGuid()}}, new ResponsibilityTask() { Id = 2, Title = "1", Site = new Site() { Id = 1}, TaskAssignedTo = new Employee() { Id = Guid.NewGuid()}}, new ResponsibilityTask() { Id = 3, Title = "1", Site = new Site() { Id = 1}, TaskAssignedTo = new Employee() { Id = Guid.NewGuid()}}}, CreatedOn = _createdOn, StatutoryResponsibilityTemplateCreatedFrom = new StatutoryResponsibilityTemplate() { Id = 2 }, Id = _originalResponsibilityId }; _user = new UserForAuditing() {CompanyId = _companyId, Id = Guid.NewGuid()}; }
public void When_Update_Then_new_values_set() { var site = new Site(); var hasAccessToAllSites = true; var doNotSendReviewDueNotification = true; var doNotSendTaskOverdueNotifications = true; var doNotSendTaskCompletedNotifications = true; var user = new UserForAuditing(); // Given var riskAssessor = new RiskAssessor(); // When riskAssessor.Update( site, hasAccessToAllSites, doNotSendReviewDueNotification, doNotSendTaskOverdueNotifications, doNotSendTaskCompletedNotifications, user ); // Then Assert.That(riskAssessor.Site == site); Assert.That(riskAssessor.HasAccessToAllSites == hasAccessToAllSites); Assert.That(riskAssessor.DoNotSendReviewDueNotification == doNotSendReviewDueNotification); Assert.That(riskAssessor.DoNotSendTaskOverdueNotifications == doNotSendTaskOverdueNotifications); Assert.That(riskAssessor.DoNotSendTaskCompletedNotifications == doNotSendTaskCompletedNotifications); Assert.That(riskAssessor.LastModifiedBy == user); Assert.That(riskAssessor.LastModifiedOn.Value.ToShortDateString() == DateTime.Today.ToShortDateString()); }
public void Given_task_is_not_reocurring_When_Complete_called_Then_task_is_completed() { var employee = new Employee {Id = Guid.NewGuid()}; var user = new User {Id = Guid.NewGuid(), Employee = employee}; var userForAuditing = new UserForAuditing {Id = Guid.NewGuid()}; var createDocumentParameterObjects1 = new List<CreateDocumentParameters> { new CreateDocumentParameters { DocumentLibraryId = 726L } }; var site = new Site {Id = 5232L}; var task = ResponsibilityTask.Create( "Test Title 1", "Test Description 1", new DateTime(2050, 10, 01), TaskStatus.Outstanding, employee, userForAuditing, createDocumentParameterObjects1, new TaskCategory {Id = 4323L}, (int) TaskReoccurringType.None, null, false, true, true, true, Guid.NewGuid(), site, new Responsibility()); var createDocumentParameterObjects2 = new List<CreateDocumentParameters> { new CreateDocumentParameters { DocumentLibraryId = 2344L } }; task.Complete( "Completed Comments 1", createDocumentParameterObjects2, new List<long>(), userForAuditing, user ); Assert.That(task.TaskStatus, Is.EqualTo(TaskStatus.Completed)); Assert.That(task.TaskCompletedComments, Is.EqualTo("Completed Comments 1")); Assert.That(task.Documents.Count, Is.EqualTo(2)); Assert.That(task.TaskCompletedBy, Is.EqualTo(userForAuditing)); Assert.That(task.LastModifiedBy, Is.EqualTo(userForAuditing)); Assert.That(task.LastModifiedOn.HasValue, Is.True); Assert.That(task.FollowingTask, Is.Null); }
public void Given_no_ancestors_When_GetThisAndAllAncestors_called_Then_one_site_returned() { //Given var site = new Site() {Id = 123, Parent = null}; //when var result = site.GetThisAndAllAncestors(); Assert.That(result.Count, Is.EqualTo(1)); }
public SiteDto MapWithChildren(Site entity) { return new SiteDto { Id = entity.Id, Name = entity.Name, ClientId = entity.ClientId, SiteId = entity.SiteId, SiteClosed = entity.SiteClosedDate != null, Children = entity.Children != null ? new SiteStructureElementDtoMapper().MapWithChildren(entity.Children).ToList() : null }; }
public SiteDto Map(Site entity) { return new SiteDto { Id = entity.Id, Name = entity.Name, ClientId = entity.ClientId, SiteId = entity.SiteId, IsMainSite = entity.IsMainSite, SiteClosed = entity.SiteClosedDate != null, }; }
public void Given_employee_is_in_list_when_AddEmployee_to_distribution_list_then_employee_is_not_duplicated() { //GIVEN var site = new Site() { Id = 123123 }; var employee = new Employee() { Id = Guid.NewGuid() }; //WHEN site.AddAccidentRecordNotificationMember(employee, new UserForAuditing()); site.AddAccidentRecordNotificationMember(employee, new UserForAuditing()); //THEN Assert.That(site.AccidentRecordNotificationMembers.Count, Is.EqualTo(1)); }
public SiteDto MapWithParent(Site entity, IEnumerable<long> childIdsThatCannotBecomeParent) { return new SiteDto { Id = entity.Id, Name = entity.Name, ClientId = entity.ClientId, SiteId = entity.SiteId, SiteContact = entity.SiteContact, SiteClosed = entity.SiteClosedDate != null, Parent = entity.Parent != null ? new SiteStructureElementDtoMapper().Map(entity.Parent) : null, ChildIdsThatCannotBecomeParent = childIdsThatCannotBecomeParent }; }
public void Given_one_ancestors_When_GetThisAndAllAncestors_called_Then_two_site_returned() { //Given var ansectorOne = new Site() {Id = 123123, Parent = null, Name = "Parent"}; var site = new Site() {Id = 123, Parent = ansectorOne, Name = "the site"}; var childSite = new Site() {Id = 432523, Parent = site, Name = "Child"}; //when var result = site.GetThisAndAllAncestors(); Assert.That(result.Count, Is.EqualTo(2)); Assert.That(result.Exists(x=> x.Name == ansectorOne.Name), Is.EqualTo(true)); Assert.That(result.Exists(x => x.Name == site.Name), Is.EqualTo(true)); }
public void Setup() { _companyId = 234246L; _responsibilityRepository = new Mock<IResponsibilityRepository>(); _employeeRepository = new Mock<IEmployeeRepository>(); _siteRepository = new Mock<ISiteRepository>(); _statutoryResponsibilityTaskTemplateRepository = new Mock<IStatutoryResponsibilityTaskTemplateRepository>(); _userForAuditingRepository = new Mock<IUserForAuditingRepository>(); _taskCategoryRepository = new Mock<ITaskCategoryRepository>(); _documentParameterHelper = new Mock<IDocumentParameterHelper>(); _log = new Mock<IPeninsulaLog>(); _responsibility = new Responsibility { Id = 1L }; _site = new Site { Id = 1L }; _statutoryResponsibilityTaskTemplate = new StatutoryResponsibilityTaskTemplate { Id = 1L }; _testUser = new UserForAuditing() {CompanyId = _companyId, Id = Guid.NewGuid()}; _employeeRepository .Setup(x => x.GetByIdAndCompanyId(It.IsAny<Guid>(), It.IsAny<long>())) .Returns(new Employee() {CompanyId = 1L, Id = Guid.NewGuid()}); _responsibilityRepository.Setup(x => x.GetByIdAndCompanyId(It.IsAny<long>(), It.IsAny<long>())) .Returns(_responsibility); _siteRepository.Setup(x => x.GetByIdAndCompanyId(It.IsAny<long>(), It.IsAny<long>())) .Returns(_site); _statutoryResponsibilityTaskTemplateRepository.Setup(x => x.GetById(It.IsAny<long>())) .Returns(_statutoryResponsibilityTaskTemplate); _userForAuditingRepository.Setup(x => x.GetById(It.IsAny<Guid>())) .Returns(_testUser); _taskCategoryRepository.Setup(x => x.GetResponsibilityTaskCategory()).Returns(new TaskCategory()); _documentParameterHelper.Setup( x => x.GetCreateDocumentParameters(It.IsAny<IEnumerable<CreateDocumentRequest>>(), It.IsAny<long>())) .Returns(new List<CreateDocumentParameters>()); }
public void Setup() { _createdBy = new UserForAuditing() { Id = Guid.NewGuid() }; _createdOn = DateTime.Now; _deleted = false; _initialTaskReoccurringType = TaskReoccurringType.FiveYearly; _lastModifiedBy = new UserForAuditing() { Id = Guid.NewGuid() }; _lastModifiedOn = DateTime.Now; _owner = new Employee() { Id = Guid.NewGuid() }; _site = new Site() { Id = 1346624L }; _responsibilityCategory = new ResponsibilityCategory() { Id = 21345642L }; _responsibilityReason = new ResponsibilityReason() { Id = 1234523L }; _statutoryResponsibilityTaskTemplate = new StatutoryResponsibilityTaskTemplate { Id = 1L }; _responsibilityTasks = new List<ResponsibilityTask> { new ResponsibilityTask { Id = 1L, Category = TaskCategory.Create(1, "Test"), StatutoryResponsibilityTaskTemplateCreatedFrom = _statutoryResponsibilityTaskTemplate } }; _entity = new Mock<Responsibility>(); _entity.Setup(x => x.Id).Returns(_id); _entity.Setup(x => x.CompanyId).Returns(_companyId); _entity.Setup(x => x.Description).Returns(_description); _entity.Setup(x => x.Site).Returns(_site); _entity.Setup(x => x.InitialTaskReoccurringType).Returns(_initialTaskReoccurringType); _entity.Setup(x => x.Owner).Returns(_owner); _entity.Setup(x => x.Title).Returns(_title); _entity.Setup(x => x.ResponsibilityCategory).Returns(_responsibilityCategory); _entity.Setup(x => x.ResponsibilityReason).Returns(_responsibilityReason); _entity.Setup(x => x.CreatedOn).Returns(_createdOn); _entity.Setup(x => x.GetStatusDerivedFromTasks()).Returns(_status); _entity.Setup(x => x.Deleted).Returns(_deleted); _entity.Setup(x => x.CreatedBy).Returns(_createdBy); _entity.Setup(x => x.LastModifiedBy).Returns(_lastModifiedBy); _entity.Setup(x => x.LastModifiedOn).Returns(_lastModifiedOn); _entity.Setup(x => x.ResponsibilityTasks).Returns(_responsibilityTasks); }
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 static ActionTask Create(string reference, string title, string description, DateTime? taskCompletionDueDate, TaskStatus taskStatus, Employee assignedTo, UserForAuditing user, IEnumerable<CreateDocumentParameters> createDocumentParameterObjects, TaskCategory taskCategory, int taskReoccurringTypeId, DateTime? taskReoccurringEndDate, bool sendTaskNotification, bool sendTaskCompletedNotification, bool sendTaskOverdueNotification, bool sendTaskDueTomorrowNotification, Guid taskGuid, Site site, Action action) { var task = new ActionTask(); task.SetValuesForCreate( reference, title, description, taskCompletionDueDate, taskStatus, assignedTo, user, createDocumentParameterObjects, taskCategory, taskReoccurringTypeId, taskReoccurringEndDate, sendTaskNotification, sendTaskCompletedNotification, sendTaskOverdueNotification, sendTaskDueTomorrowNotification, taskGuid, site); task.Action = action; action.AddTask(task); action.SetLastModifiedBy(user); return task; }
public void SetUp() { _nsbSystemUser = new UserForAuditing(); _userRepo = new Mock<IUserRepository>(); _userForAuditingRepo = new Mock<IUserForAuditingRepository>(); _userForAuditingRepo.Setup(x => x.GetSystemUser()).Returns(_nsbSystemUser); _userRepo.Setup(x => x.Save(It.IsAny<User>())); _adminRole = new Role(); _roleRepo = new Mock<IRoleRepository>(); _roleRepo.Setup(x => x.GetAdminRole()).Returns(_adminRole); _rootSite = new Site(); _siteRepo = new Mock<ISiteRepository>(); _siteRepo.Setup(x => x.GetRootSiteByCompanyId(It.IsAny<long>())).Returns(_rootSite); _log = new Mock<IPeninsulaLog>(); }
public void Given_site_exists_when_AddNonEmployeeToAccidentRecordNotificationMembers_Then_employee_added_to_site_distribution_list() { // given long siteId = 1234; Guid employeeId = Guid.NewGuid(); Guid userId = Guid.NewGuid(); Site savedSite = null; _siteAddressRepository .Setup(x => x.SaveOrUpdate(It.IsAny<Site>())) .Callback<Site>(y => savedSite = y); var site = new Site(); site.Id = siteId; _siteAddressRepository .Setup(x => x.GetById(site.Id)) .Returns(() => site); string nonEmployeeEmail = "*****@*****.**"; string nonEmployeeName = "Norman Notemployedhere"; UserForAuditing user = new UserForAuditing() { Id = Guid.NewGuid() }; _userForAuditingRepository .Setup(x => x.GetByIdAndCompanyId(It.IsAny<Guid>(), It.IsAny<long>())) .Returns(user); // when var target = CreateSiteService(); target.AddNonEmployeeToAccidentRecordNotificationMembers(siteId, nonEmployeeName, nonEmployeeEmail, userId); // then Assert.IsNotNull(savedSite.AccidentRecordNotificationMembers); Assert.AreEqual(1, savedSite.AccidentRecordNotificationMembers.Count); Assert.AreEqual(nonEmployeeName, savedSite.AccidentRecordNotificationMembers[0].FullName()); Assert.AreEqual(nonEmployeeEmail, savedSite.AccidentRecordNotificationMembers[0].Email()); }
public void SetUp() { _clientId = 3423L; _currentUser = new UserForAuditing { Id = Guid.NewGuid() }; _location = "Manchester"; _taskProcessDescription = "Process"; _site = new Site { Id = 256L }; _assessmentDate = new DateTime(2051, 10, 1); _riskAssessor = new RiskAssessor { Id = 74747L }; _hazardTypes = new List<HazardType> { new HazardType {Id = 25L}, new HazardType {Id = 37L} }; _generalRiskAssessment = GeneralRiskAssessment.Create( "General Risk Assessment 2", "GRA02", _clientId, _currentUser, _location, _taskProcessDescription, _site, _assessmentDate, _riskAssessor); }
public virtual void Update( string title, string description, DateTime? taskCompletionDueDate, TaskStatus taskStatus, Employee assignedTo, UserForAuditing user, IEnumerable<CreateDocumentParameters> createDocumentParameterObjects, TaskCategory taskCategory, int taskReoccurringTypeId, DateTime? taskReoccurringEndDate, bool sendTaskNotification, bool sendTaskCompletedNotification, bool sendTaskOverdueNotification, bool sendTaskDueTomorrowNotification, Guid taskGuid, Site site) { Title = title; Description = description; TaskCompletionDueDate = taskCompletionDueDate.HasValue ? taskCompletionDueDate.Value : (DateTime?) null; TaskAssignedTo = assignedTo; TaskStatus = taskStatus; CreatedOn = DateTime.Now; CreatedBy = user; SetTaskReoccurringType((TaskReoccurringType) taskReoccurringTypeId); TaskReoccurringEndDate = taskReoccurringEndDate; OriginalTask = this; LastModifiedBy = user; LastModifiedOn = DateTime.Now; AddDocumentsToTask(createDocumentParameterObjects, user); TaskGuid = taskGuid; SendTaskNotification = sendTaskNotification; SendTaskCompletedNotification = sendTaskCompletedNotification; SendTaskOverdueNotification = sendTaskOverdueNotification; SendTaskDueTomorrowNotification = sendTaskDueTomorrowNotification; Site = site; Responsibility.SetLastModifiedBy(user); }
public void When_Create_Then_Return_Responsibility() { // Given var category = new ResponsibilityCategory(); const string title = "R1"; const string description = "R Test"; var site = new Site(); var reason = new ResponsibilityReason(); var owner = new Employee (); const TaskReoccurringType frequency = TaskReoccurringType.Weekly; var user = new UserForAuditing(); var template = new StatutoryResponsibilityTemplate(); // When var result = Responsibility.Create(default(long), category, title, description, site, reason, owner, frequency, template, user ); // Then Assert.AreEqual(category,result.ResponsibilityCategory); Assert.AreEqual(title,result.Title); Assert.AreEqual(description,result.Description); Assert.AreEqual(site,result.Site); Assert.AreEqual(reason,result.ResponsibilityReason); Assert.AreEqual(owner,result.Owner); Assert.AreEqual(frequency,result.InitialTaskReoccurringType); Assert.AreEqual(user,result.CreatedBy); Assert.AreEqual(template, result.StatutoryResponsibilityTemplateCreatedFrom); Assert.That(result, Is.InstanceOf<Responsibility>()); }
private static ResponsibilityTask GetResponsibilityTask( SaveResponsibilityTaskRequest request, Employee employee, UserForAuditing user, TaskCategory taskCategory, Responsibility responsibility, Site site, IEnumerable<CreateDocumentParameters> createDocumentParameters) { ResponsibilityTask task; if (request.TaskId != default(long)) { task = responsibility.ResponsibilityTasks.FirstOrDefault(t => t.Id == request.TaskId); if (task != null) { task.Update( request.Title, request.Description, request.TaskCompletionDueDate, request.TaskStatus, employee, user, createDocumentParameters, taskCategory, request.TaskReoccurringTypeId, request.TaskReoccurringEndDate, request.SendTaskNotification, request.SendTaskCompletedNotification, request.SendTaskOverdueNotification, request.SendTaskDueTomorrowNotification, request.TaskGuid, site ); } } else { task = ResponsibilityTask.Create( request.Title, request.Description, request.TaskCompletionDueDate, request.TaskStatus, employee, user, createDocumentParameters, taskCategory, request.TaskReoccurringTypeId, request.TaskReoccurringEndDate, request.SendTaskNotification, request.SendTaskCompletedNotification, request.SendTaskOverdueNotification, request.SendTaskDueTomorrowNotification, request.TaskGuid, site, responsibility ); } return task; }
public SiteStructureElement GetSampleSiteStructure() { var siteStructure = new Site { Id = 11, Name = "Head Office", Children = new List<SiteStructureElement> { new SiteGroup { Id = 21, Name = "North West Region", Deleted = true, Children = new List<SiteStructureElement> { new Site { Id = 31, Name = "Manchester City Centre", Deleted = true, Children = new List<SiteStructureElement> { new Site { Id = 41, Name = "Chorlton", Deleted = true }, new Site { Id = 42, Name = "Didsbury", Deleted = true }, } }, new Site { Id = 32, Name = "Liverpool City Center", Deleted = true, Children = new List<SiteStructureElement> { new Site { Id = 43, Name = "Liverpool One", Deleted = true } } } } }, new SiteGroup { Id = 22, Name = "Midlands Region", Children = new List<SiteStructureElement> { new SiteGroup { Id = 33, Name = "East Midlands Region", Children = new List<SiteStructureElement> { new Site { Id = 44, Name = "Nottingham" }, new Site { Id = 45, Name = "Leicester" } } }, new SiteGroup { Id = 34, Name = "West Midlands Region", Children = new List<SiteStructureElement> { new Site { Id = 46, Name = "Birmingham" } } } } } } }; return siteStructure; }
public void Setup() { _siteId = 456L; _companyId = 123L; _employeeId = Guid.NewGuid(); _userForAuditingId = Guid.NewGuid(); _request = new CreateEditRiskAssessorRequest() { CompanyId = _companyId, CreatingUserId = _userForAuditingId, DoNotSendReviewDueNotification = true, DoNotSendTaskCompletedNotifications = false, DoNotSendTaskOverdueNotifications = true, EmployeeId = _employeeId, SiteId = _siteId, HasAccessToAllSites = false }; _riskAssessorRepository = new Mock<IRiskAssessorRepository>(); _riskAssessorRepository .Setup(x => x.GetByIdAndCompanyId(It.IsAny<long>(), It.IsAny<long>())) .Returns(new RiskAssessor()); _riskAssessorRepository .Setup(x => x.Save(It.IsAny<RiskAssessor>())); _employee = new Employee() { Id = _employeeId, CompanyId = _companyId }; _employeeRepository = new Mock<IEmployeeRepository>(); _employeeRepository .Setup(x => x.GetByIdAndCompanyId(_employee.Id, _employee.CompanyId)) .Returns(_employee); _site = new Site { Id = _siteId, ClientId = _companyId, Name = "Middle Earth" }; _siteRepository = new Mock<ISiteRepository>(); _siteRepository .Setup(x => x.GetByIdAndCompanyId(_siteId, _companyId)) .Returns(_site); _siteStructureElementRepository = new Mock<ISiteStructureElementRepository>(); _siteStructureElementRepository .Setup(x => x.GetByIdAndCompanyId(_siteId, _companyId)) .Returns(_site); _userForAuditing = new UserForAuditing { Id = _userForAuditingId, CompanyId = _companyId }; _userForAuditingRepository = new Mock<IUserForAuditingRepository>(); _userForAuditingRepository .Setup(x => x.GetByIdAndCompanyId(_userForAuditingId, _companyId)) .Returns(_userForAuditing); _riskAssessor = new RiskAssessor { Id = 1119L }; _log = new Mock<IPeninsulaLog>(); _log .Setup(x => x.Add(It.IsAny<object>())); }