public void Given_valid_request_When_UpdateRiskAssessmentPremisesInformation_Then_calls_the_correct_methods() { //Given var riskAssessmentService = CreateRiskAssessmentService(); var request = new SaveRiskAssessmentPremisesInformationRequest() { CompanyId = CompanyId, Id = RiskAssessmentId, UserId = Guid.NewGuid(), LocationAreaDepartment = "Test Location", TaskProcessDescription = "Test Task" }; var mockRiskAssessment = new Mock<MultiHazardRiskAssessment>(); _multiHazardRiskAssessmentRepository .Setup(rr => rr.GetByIdAndCompanyId(RiskAssessmentId, CompanyId)) .Returns(mockRiskAssessment.Object); var user = new UserForAuditing(); _userRepository .Setup(x => x.GetByIdAndCompanyId(request.UserId, request.CompanyId)) .Returns(user); //When riskAssessmentService.UpdateRiskAssessmentPremisesInformation(request); //Then mockRiskAssessment.Verify(x => x.UpdatePremisesInformation(request.LocationAreaDepartment,request.TaskProcessDescription, user)); _multiHazardRiskAssessmentRepository.Verify(x => x.SaveOrUpdate(mockRiskAssessment.Object)); _userRepository.VerifyAll(); }
public void UpdateRiskAssessmentPremisesInformation(SaveRiskAssessmentPremisesInformationRequest request) { _log.Add(request); try { var user = _userForAuditingRepository.GetByIdAndCompanyId(request.UserId, request.CompanyId); var riskAssessment = _multiHazardRiskAssessmentRepository.GetByIdAndCompanyId(request.Id, request.CompanyId); riskAssessment.UpdatePremisesInformation( request.LocationAreaDepartment, request.TaskProcessDescription, user); _multiHazardRiskAssessmentRepository.SaveOrUpdate(riskAssessment); } catch (Exception ex) { _log.Add(ex); throw; } }