public void When_GetViewModel_Then_should_call_the_correct_methods() { // Given var target = GetTarget(); var riskAssessment = new PersonalRiskAssessmentDto() { CompanyId = _companyId, Id = _riskAssessmentId, NonEmployees = new RiskAssessmentNonEmployeeDto[] { }, Employees = new RiskAssessmentEmployeeDto[] { }, RiskAssessmentSite = new SiteDto() }; _riskAssessmentService .Setup(x => x.GetRiskAssessment(_riskAssessmentId, _companyId, _currentUserId)) .Returns(riskAssessment); // When target .WithCompanyId(_companyId) .WithRiskAssessmentId(_riskAssessmentId) .WithCurrentUserId(_currentUserId) .GetViewModel(); // Then _riskAssessmentService.VerifyAll(); }
public void Setup() { _currentUserId = Guid.NewGuid(); _riskAssessment = new PersonalRiskAssessmentDto() { Id = _riskAssessmentId, CompanyId = _companyId, CreatedBy = new AuditedUserDto() { Id = _currentUserId }, Title = "title", Sensitive = true, }; _riskAssessmentService = new Mock<IPersonalRiskAssessmentService>(); _riskAssessmentService .Setup(x => x.GetWithReviews(_riskAssessmentId, _companyId, It.IsAny<Guid>())) .Returns(_riskAssessment); _employeeService = new Mock<IEmployeeService>(); _employeeService .Setup(x => x.Search(It.IsAny<SearchEmployeesRequest>())) .Returns(new List<EmployeeDto>()); _siteService = new Mock<ISiteService>(); _target = GetTarget(); }
public void SetUp() { _riskAssessmentService = new Mock<IPersonalRiskAssessmentService>(); var riskAssessment = new PersonalRiskAssessmentDto(); _target = GetTarget(); _currentUserId = _target.CurrentUser.UserId; _riskAssessmentService .Setup(x => x.GetRiskAssessmentWithHazards(_riskAssessmentId, _companyId, _currentUserId)) .Returns(riskAssessment); }
private bool IsLoggedInUserAssessor(PersonalRiskAssessmentDto riskAssessment) { bool isLoggedInUserAssessor = false; if (riskAssessment.RiskAssessor != null && riskAssessment.RiskAssessor.Employee != null) { var employee = _employeeService.GetEmployee(riskAssessment.RiskAssessor.Employee.Id, _companyId); if (employee != null && employee.User != null && employee.User.Id == _currentUserId) { isLoggedInUserAssessor = true; } } return isLoggedInUserAssessor; }
public void Setup() { _currentUserId = Guid.NewGuid(); _employee1 = new EmployeeDto() { FullName = "Barry Griffthes", MainContactDetails = new EmployeeContactDetailDto { Email = "*****@*****.**" } }; _checklist1 = new ChecklistDto() { Title = "Title 1" }; var employeeChecklist1 = new EmployeeChecklistDto { Employee = _employee1, Checklist = _checklist1, CompletedDate = DateTime.Now, Id = Guid.NewGuid(), IsFurtherActionRequired = true }; _employee2 = new EmployeeDto() { FullName = "Dave Smith", MainContactDetails = new EmployeeContactDetailDto { Email = "*****@*****.**" } }; _checklist2 = new ChecklistDto() { Title = "Title 2" }; var employeeChecklist2 = new EmployeeChecklistDto { Employee = _employee2, Checklist = _checklist2, Id = Guid.NewGuid(), }; _employeeChecklists = new List<EmployeeChecklistDto> { employeeChecklist1, employeeChecklist2 }; _personalRiskAssessmentDto = new PersonalRiskAssessmentDto {EmployeeChecklists = _employeeChecklists, PersonalRiskAssessementEmployeeChecklistStatus = PersonalRiskAssessementEmployeeChecklistStatusEnum.Generated}; _personalRiskAssessmentService = new Mock<IPersonalRiskAssessmentService>(); }
public void When_GetViewModel_Then_should_call_the_correct_result() { // Given var target = GetTarget(); var riskAssessment = new PersonalRiskAssessmentDto() { CompanyId = _companyId, Id = _riskAssessmentId, Employees = new[] { new RiskAssessmentEmployeeDto{ Employee = new EmployeeDto() } }, NonEmployees = new[] { new RiskAssessmentNonEmployeeDto{ NonEmployee = new NonEmployeeDto() } }, RiskAssessmentSite = new SiteDto() { Id = 200 }, Location = "Test Location", TaskProcessDescription = "Test Task Process Description" }; _riskAssessmentService .Setup(x => x.GetRiskAssessment(_riskAssessmentId, _companyId, _currentUserId)) .Returns(riskAssessment); // When var result = target .WithCompanyId(_companyId) .WithRiskAssessmentId(_riskAssessmentId) .WithCurrentUserId(_currentUserId) .GetViewModel(); // Then Assert.That(result.CompanyId, Is.EqualTo(_companyId)); Assert.That(result.RiskAssessmentId, Is.EqualTo(_riskAssessmentId)); Assert.That(result.Employees.Count(), Is.EqualTo(riskAssessment.Employees.Count())); Assert.That(result.NonEmployees.Count(), Is.EqualTo(riskAssessment.NonEmployees.Count())); Assert.That(result.LocationAreaDepartment, Is.EqualTo(riskAssessment.Location)); Assert.That(result.TaskProcessDescription, Is.EqualTo(riskAssessment.TaskProcessDescription)); }
public void Correct_employees_are_displayed_in_drop_down_list_for_single_employee() { _basePersonalRiskAssessment = new PersonalRiskAssessmentDto { Id = _riskAssessmentId, ChecklistGeneratorEmployees = new[] { _employees[0] }, Checklists = new ChecklistDto[0] }; _personalRiskAssessmentService .Setup(x => x.GetWithChecklistGeneratorEmployeesAndChecklists(_riskAssessmentId, _companyId, _currentUserId)) .Returns(_basePersonalRiskAssessment); var viewResult = _target.Index(_riskAssessmentId, _companyId) as ViewResult; var viewModel = viewResult.Model as EmployeeChecklistGeneratorViewModel; var employees = viewModel.Employees.ToList(); Assert.That(employees.Count(), Is.EqualTo(4)); Assert.That(employees[0].label, Is.EqualTo("--Select Option--")); Assert.That(employees[0].value, Is.Empty); Assert.That(employees[1].label, Is.EqualTo("Mark Mauve ([email protected])")); Assert.That(employees[1].value, Is.EqualTo(_employees[0].Id.ToString())); Assert.That(employees[2].label, Is.EqualTo("Peter Pink")); Assert.That(employees[2].value, Is.EqualTo(_employees[1].Id.ToString())); Assert.That(employees[3].label, Is.EqualTo("Guy Grey ([email protected])")); Assert.That(employees[3].value, Is.EqualTo(_employees[2].Id.ToString())); }
public void Given_factory_takes_viewmodel_When_GetViewModel_Then_should_call_the_correct_methods() { // Given var target = GetTarget(); var riskAssessment = new PersonalRiskAssessmentDto() { CompanyId = _companyId, Id = _riskAssessmentId, NonEmployees = new RiskAssessmentNonEmployeeDto[] { }, Employees = new RiskAssessmentEmployeeDto[] { }, RiskAssessmentSite = new SiteDto() }; var viewModel = new PremisesInformationViewModel() { RiskAssessmentId = _riskAssessmentId, CompanyId = _companyId }; _riskAssessmentService .Setup(x => x.GetRiskAssessment(viewModel.RiskAssessmentId, viewModel.CompanyId, _currentUserId)) .Returns(riskAssessment); // When target .WithCompanyId(viewModel.CompanyId) .WithRiskAssessmentId(viewModel.RiskAssessmentId) .WithCurrentUserId(_currentUserId) .GetViewModel(viewModel); // Then _riskAssessmentService.VerifyAll(); }
private void SetChecklistGeneratorEmployees(PersonalRiskAssessmentDto personalRiskAssessment, EmployeeChecklistGeneratorViewModel viewModel) { if (personalRiskAssessment.ChecklistGeneratorEmployees.Count() == 1) { viewModel.IsForMultipleEmployees = "single"; viewModel.SingleEmployeesSectionVisible = true; var employee = personalRiskAssessment.ChecklistGeneratorEmployees.ToList()[0]; if (employee.MainContactDetails == null || string.IsNullOrEmpty(employee.MainContactDetails.Email)) { viewModel.NewEmployeeEmailVisible = true; viewModel.ExistingEmployeeEmailVisible = false; } else { viewModel.NewEmployeeEmailVisible = false; viewModel.ExistingEmployeeEmailVisible = true; viewModel.ExistingEmployeeEmail = employee.MainContactDetails.Email; } viewModel.EmployeeId = employee.Id; } if (personalRiskAssessment.ChecklistGeneratorEmployees.Count() > 1) { viewModel.IsForMultipleEmployees = "multiple"; viewModel.MultipleEmployeesSectionVisible = true; viewModel.MultiSelectedEmployees = _selectedEmployeeViewModelFactory .WithCompanyId(_companyId) .WithRiskAssessmentId(_riskAssessmentId) .WithUserId(_currentUserId) .GetViewModel(); } }
public void When_RiskAssessment_Not_In_Users_Allowed_Sites_Then_Throw_Exception() { // Given const long riskAssessmentId = 1234; var riskAssessment = new PersonalRiskAssessmentDto() { Id = 1, RiskAssessmentSite = new SiteStructureElementDto(){Id = 2} }; _riskAssessmentService .Setup(x => x.GetRiskAssessment(riskAssessmentId, 1, TestControllerHelpers.UserIdAssigned)) .Returns(riskAssessment); var target = GetTarget(); // When // Then Assert.Throws<SitePermissionsInvalidForUserException>(() => target.Index(riskAssessmentId)); _riskAssessmentService.Verify(x => x.GetRiskAssessment(It.IsAny<long>(), It.IsAny<long>(), It.IsAny<Guid>())); }
public void When_valid_RiskAssessment_requested_Then_returned_filename_is_RiskAssessment_Sanitised_Title(string input, string output) { // Given var target = GetTarget(); const string filename = "filename"; const string mimeType = "mimetype"; var riskAssessment = new PersonalRiskAssessmentDto() { Id = 1234, Title = input, CreatedBy = new AuditedUserDto() { Id = target.CurrentUser.UserId } }; _riskAssessmentService .Setup(x => x.GetRiskAssessment(riskAssessment.Id, 1, TestControllerHelpers.UserIdAssigned)) .Returns(riskAssessment); _reportExecutionServiceFacade .Setup(x => x.GetReport( It.IsAny<SqlReportHelper.ReportType>(), new object[] { riskAssessment.Id }, It.IsAny<SqlReportHelper.ReportFormatType>() )) .Returns(new DocumentViewModel() { FileName = filename, FileStream = new MemoryStream(), MimeType = mimeType }); // When var result = target.Index(riskAssessment.Id); // Then Assert.That(result.FileDownloadName, Is.EqualTo(output)); }
public void Setup() { _employeeService = new Mock<IEmployeeService>(); _employeeChecklistEmailService = new Mock<IEmployeeChecklistEmailService>(); _personalRiskAssessmentService = new Mock<IPersonalRiskAssessmentService>(); _checklistService = new Mock<IChecklistService>(); _siteService = new Mock<ISiteService>(); _businessSafeSessionManager=new Mock<IBusinessSafeSessionManager>(); _bus = new Mock<IBus>(); _selectedEmployeeViewModelFactory = new SelectedEmployeeViewModelFactory(_personalRiskAssessmentService.Object); _checklistGeneratorViewModelFactory = new EmployeeChecklistGeneratorViewModelFactory(_employeeService.Object, _checklistService.Object, _personalRiskAssessmentService.Object, _siteService.Object, _selectedEmployeeViewModelFactory); _companyId = 23522L; _riskAssessmentId = 342L; _message = "Test Message"; _employees = new List<EmployeeDto> { new EmployeeDto { Id = _currentUserId, FullName = "Mark Mauve", MainContactDetails = new EmployeeContactDetailDto{ Email = "*****@*****.**"} }, new EmployeeDto { Id = new Guid("cf7ce0b2-8a97-4c32-8af1-ce3c96716fdd"), FullName = "Peter Pink" }, new EmployeeDto { Id = new Guid("0b20512d-3b4e-4da3-ab8c-6433c3fa4118"), FullName = "Guy Grey", MainContactDetails = new EmployeeContactDetailDto{ Email = "*****@*****.**"} } }; _checklists = new List<ChecklistDto> { new ChecklistDto { Id = 1L, Title = "Test Checklist 01" }, new ChecklistDto { Id = 2L, Title = "Test Checklist 02" }, new ChecklistDto { Id = 3L, Title = "Test Checklist 03" }, }; _basePersonalRiskAssessment = new PersonalRiskAssessmentDto { Id = _riskAssessmentId, ChecklistGeneratorEmployees = new EmployeeDto[0], Checklists = new ChecklistDto[0], ChecklistGeneratorMessage = _message }; _target = GetTarget(); _currentUserId = _target.CurrentUser.UserId; _employeeService .Setup(x => x.GetAll(_companyId)) .Returns(_employees); _checklistService .Setup(x => x.GetByRiskAssessmentType(ChecklistRiskAssessmentType.Personal)) .Returns(_checklists); _siteService .Setup(x => x.GetAll(_companyId)) .Returns(new List<SiteDto>()); }
public void When_RiskAssessment_With_No_SiteId_requested_That_The_User_Created_Then_return_FileResult() { // Given const long riskAssessmentId = 1234; var target = GetTarget(); var riskAssessment = new PersonalRiskAssessmentDto() { Id = 1, RiskAssessmentSite = null, Title = "My GRA", CreatedBy = new AuditedUserDto() { Id = target.CurrentUser.UserId } }; _riskAssessmentService .Setup(x => x.GetRiskAssessment(riskAssessmentId, 1, TestControllerHelpers.UserIdAssigned)) .Returns(riskAssessment); // When var result = target.Index(riskAssessmentId); // Then Assert.IsInstanceOf<FileResult>(result); }
public void Existing_new_email_textbox_is_displayed_for_single_employee_without_email() { _basePersonalRiskAssessment = new PersonalRiskAssessmentDto { Id = _riskAssessmentId, ChecklistGeneratorEmployees = new[] { _employees[1] }, Checklists = new ChecklistDto[0] }; _personalRiskAssessmentService .Setup(x => x.GetWithChecklistGeneratorEmployeesAndChecklists(_riskAssessmentId, _companyId, _currentUserId)) .Returns(_basePersonalRiskAssessment); var viewResult = _target.Index(_riskAssessmentId, _companyId) as ViewResult; var viewModel = viewResult.Model as EmployeeChecklistGeneratorViewModel; Assert.That(viewModel.ExistingEmployeeEmailVisible, Is.False); Assert.That(viewModel.NewEmployeeEmailVisible, Is.True); Assert.That(viewModel.ExistingEmployeeEmail, Is.Null); }
public void Setup() { _currentUserId = Guid.NewGuid(); _employeeService = new Mock<IEmployeeService>(); _employees = new List<EmployeeDto> { new EmployeeDto { Id = Guid.NewGuid(), FullName = "percy purple", Surname = "Purple", MainContactDetails = new EmployeeContactDetailDto{ Email = "*****@*****.**"} }, new EmployeeDto { Id = Guid.NewGuid(), FullName = "rachel red", Surname = "Red" }, new EmployeeDto { Id = Guid.NewGuid(), FullName = "Barry Brown", Surname = "brown" }, new EmployeeDto { Id = Guid.NewGuid(), FullName = "cyril cyan", Surname = "cyan", MainContactDetails = new EmployeeContactDetailDto{ Email = "" } }, new EmployeeDto { Id = Guid.NewGuid(), FullName = "Xavi Xander", Surname = "xander" }, new EmployeeDto { Id = Guid.NewGuid(), FullName = "Armstrong Armstrong", Surname = "armstrong", MainContactDetails = new EmployeeContactDetailDto{ Email = "*****@*****.**"} } }; _employeeService.Setup(x => x.GetAll(_companyId)). Returns(_employees); _checklists = new List<ChecklistDto>() { new ChecklistDto() {Id = 1, Title = "checklist 1"}, new ChecklistDto() {Id = 2, Title = "checklist 2"}, new ChecklistDto() {Id = 3, Title = "checklist 3"}, new ChecklistDto() {Id = 4, Title = "checklist 4"} }; _checklistService = new Mock<IChecklistService>(); _checklistService .Setup(x => x.GetByRiskAssessmentType(ChecklistRiskAssessmentType.Personal)) .Returns(_checklists); _personalRiskAssessmentDto = new PersonalRiskAssessmentDto { ChecklistGeneratorEmployees = _employees, Checklists = _checklists }; _personalRiskAssessmentService = new Mock<IPersonalRiskAssessmentService>(); _personalRiskAssessmentService .Setup(x => x.GetWithChecklistGeneratorEmployeesAndChecklists(It.IsAny<long>(), It.IsAny<long>(), _currentUserId)) .Returns(() => _personalRiskAssessmentDto); _siteService = new Mock<ISiteService>(); _siteService .Setup(x => x.GetAll(_companyId)) .Returns(new List<SiteDto>()); _selectedEmployeeViewModelFactory = new SelectedEmployeeViewModelFactory(_personalRiskAssessmentService.Object); }
public RiskAssessmentDto MapWithSiteAndRiskAssessor(RiskAssessment entity) { RiskAssessmentDto dto = null; if (entity.Self as MultiHazardRiskAssessment != null) { if(entity.Self as PersonalRiskAssessment != null) { dto = new PersonalRiskAssessmentDto(); var personalRiskAssessment = entity.Self as PersonalRiskAssessment; var personalRiskAssessmentDto = dto as PersonalRiskAssessmentDto; personalRiskAssessmentDto.Sensitive = personalRiskAssessment.Sensitive; personalRiskAssessmentDto.ChecklistGeneratorMessage = personalRiskAssessment.ChecklistGeneratorMessage; personalRiskAssessmentDto.PersonalRiskAssessementEmployeeChecklistStatus = personalRiskAssessment.PersonalRiskAssessementEmployeeChecklistStatus; personalRiskAssessmentDto.SendCompletedChecklistNotificationEmail = personalRiskAssessment.SendCompletedChecklistNotificationEmail; personalRiskAssessmentDto.CompletionDueDateForChecklists = personalRiskAssessment.CompletionDueDateForChecklists; personalRiskAssessmentDto.CompletionNotificationEmailAddress = personalRiskAssessment.CompletionNotificationEmailAddress; personalRiskAssessmentDto.Hazards = personalRiskAssessment.Hazards.ToList().Select(h => HazardDtoMapper.Map(h)).ToList(); } if(entity.Self as GeneralRiskAssessment != null) { dto = new GeneralRiskAssessmentDto(); } var multiHazardRiskAssessmentDto = dto as MultiHazardRiskAssessmentDto; var multiHazardRiskAssessment = entity.Self as MultiHazardRiskAssessment; if (multiHazardRiskAssessment != null) { multiHazardRiskAssessmentDto.Location = multiHazardRiskAssessment.Location; multiHazardRiskAssessmentDto.TaskProcessDescription = multiHazardRiskAssessment.TaskProcessDescription; multiHazardRiskAssessmentDto.CompletionDueDate = multiHazardRiskAssessment.CompletionDueDate; } } else if(entity.Self as FireRiskAssessment != null) { dto = new FireRiskAssessmentDto(); var fireRiskAssessment = entity.Self as FireRiskAssessment; var fireRiskAssessmentDto = dto as FireRiskAssessmentDto; fireRiskAssessmentDto.PersonAppointed = fireRiskAssessment.PersonAppointed; fireRiskAssessmentDto.PremisesProvidesSleepingAccommodation = fireRiskAssessment.PremisesProvidesSleepingAccommodation; fireRiskAssessmentDto.PremisesProvidesSleepingAccommodationConfirmed = fireRiskAssessment.PremisesProvidesSleepingAccommodationConfirmed; fireRiskAssessmentDto.Location = fireRiskAssessment.Location; fireRiskAssessmentDto.BuildingUse = fireRiskAssessment.BuildingUse; fireRiskAssessmentDto.NumberOfFloors = fireRiskAssessment.NumberOfFloors; fireRiskAssessmentDto.NumberOfPeople = fireRiskAssessment.NumberOfPeople; fireRiskAssessmentDto.ElectricityEmergencyShutOff = fireRiskAssessment.ElectricityEmergencyShutOff; fireRiskAssessmentDto.WaterEmergencyShutOff = fireRiskAssessment.WaterEmergencyShutOff; fireRiskAssessmentDto.GasEmergencyShutOff = fireRiskAssessment.GasEmergencyShutOff; fireRiskAssessmentDto.OtherEmergencyShutOff = fireRiskAssessment.OtherEmergencyShutOff; fireRiskAssessmentDto.CompletionDueDate = fireRiskAssessment.CompletionDueDate; } else { dto = new RiskAssessmentDto(); } dto.Id = entity.Id; dto.AssessmentDate = entity.AssessmentDate; dto.CreatedOn = entity.CreatedOn; dto.CompanyId = entity.CompanyId; dto.Reference = entity.Reference; dto.Status = entity.Status; dto.Title = entity.Title; dto.Deleted = entity.Deleted; dto.CreatedBy = entity.CreatedBy != null ? new AuditedUserDtoMapper().Map(entity.CreatedBy) : null; dto.RiskAssessmentSite = entity.RiskAssessmentSite != null ? new SiteStructureElementDtoMapper().Map(entity.RiskAssessmentSite) : null; dto.RiskAssessor = entity.RiskAssessor != null ? new RiskAssessorDtoMapper().MapWithEmployee(entity.RiskAssessor) : null; dto.NextReviewDate = entity.NextReviewDate; //Required for the API dto.Reviews = entity.Reviews != null ? entity.Reviews.Select(review => new RiskAssessmentReviewDto() { Comments = review.Comments ,CompletedBy = review.CompletedBy != null ? new EmployeeDtoMapper().Map(review.CompletedBy) : null ,CompletedDate = review.CompletedDate ,CompletionDueDate = review.CompletionDueDate, Id = review.Id, IsReviewOutstanding = review.IsReviewOutstanding ,ReviewAssignedTo = review.ReviewAssignedTo != null ? new EmployeeDtoMapper().Map(review.ReviewAssignedTo) : null }).ToList() : new List<RiskAssessmentReviewDto>(); return dto; }
private bool IsLoggedInUserReviewer(PersonalRiskAssessmentDto riskAssessment) { bool isLoggedInUserReviewer = false; if (riskAssessment.Reviews != null) { isLoggedInUserReviewer = riskAssessment.Reviews.Any(x => x.ReviewAssignedTo.User != null && x.ReviewAssignedTo.User.Id == _currentUserId && x.CompletedDate == null); } return isLoggedInUserReviewer; }
private bool IsLoggedInUserCreator(PersonalRiskAssessmentDto riskAssessment) { return riskAssessment.CreatedBy.Id == _currentUserId; }
public void When_RiskAssessment_With_No_SiteId_requested_That_Was_Created_By_Another_User_Then_Throw_Exception() { // Given const long riskAssessmentId = 1234; var target = GetTarget(); var riskAssessment = new PersonalRiskAssessmentDto() { Id = 1, RiskAssessmentSite = null, Title = "My GRA", CreatedBy = new AuditedUserDto() { Id = Guid.NewGuid() } }; _riskAssessmentService .Setup(x => x.GetRiskAssessment(riskAssessmentId, 1, TestControllerHelpers.UserIdAssigned)) .Returns(riskAssessment); // When // Then Assert.Throws<SitePermissionsInvalidForUserException>(() => target.Index(riskAssessmentId)); }
public void Correct_IsForMultipleEmployees_is_returned_for_multiple_employees() { _basePersonalRiskAssessment = new PersonalRiskAssessmentDto { Id = _riskAssessmentId, ChecklistGeneratorEmployees = new[] { _employees[0], _employees[1] }, Checklists = new ChecklistDto[0] }; _personalRiskAssessmentService .Setup(x => x.GetWithChecklistGeneratorEmployeesAndChecklists(_riskAssessmentId, _companyId, _currentUserId)) .Returns(_basePersonalRiskAssessment); var viewResult = _target.Index(_riskAssessmentId, _companyId) as ViewResult; var viewModel = viewResult.Model as EmployeeChecklistGeneratorViewModel; Assert.That(viewModel.IsForMultipleEmployees, Is.EqualTo("multiple")); Assert.That(viewModel.SingleEmployeesSectionVisible, Is.False); //Could go in separate test, but do we really want to??? Assert.That(viewModel.MultipleEmployeesSectionVisible, Is.True); //Could go in separate test, but do we really want to??? }
public void Correct_checklists_are_displayed() { // Given _basePersonalRiskAssessment = new PersonalRiskAssessmentDto { Id = _riskAssessmentId, ChecklistGeneratorEmployees = new[] { _employees[0] }, Checklists = new[] { _checklists[0], _checklists[2] } }; _personalRiskAssessmentService .Setup(x => x.GetWithChecklistGeneratorEmployeesAndChecklists(_riskAssessmentId, _companyId, _currentUserId)) .Returns(_basePersonalRiskAssessment); // When var viewResult = _target.Index(_riskAssessmentId, _companyId) as ViewResult; var viewModel = viewResult.Model as EmployeeChecklistGeneratorViewModel; // Then Assert.That(viewModel.Checklists.Count, Is.EqualTo(3)); Assert.That(viewModel.Checklists[0].Id, Is.EqualTo(1)); Assert.That(viewModel.Checklists[0].Title, Is.EqualTo("Test Checklist 01")); Assert.That(viewModel.Checklists[0].ControlId, Is.EqualTo("IncludeChecklist_1")); Assert.That(viewModel.Checklists[0].Checked, Is.True); Assert.That(viewModel.Checklists[1].Id, Is.EqualTo(2)); Assert.That(viewModel.Checklists[1].Title, Is.EqualTo("Test Checklist 02")); Assert.That(viewModel.Checklists[1].ControlId, Is.EqualTo("IncludeChecklist_2")); Assert.That(viewModel.Checklists[1].Checked, Is.False); Assert.That(viewModel.Checklists[2].Id, Is.EqualTo(3)); Assert.That(viewModel.Checklists[2].Title, Is.EqualTo("Test Checklist 03")); Assert.That(viewModel.Checklists[2].ControlId, Is.EqualTo("IncludeChecklist_3")); Assert.That(viewModel.Checklists[2].Checked, Is.True); Assert.That(viewModel.EmployeeId, Is.EqualTo(_employees[0].Id)); }