public void Setup()
        {
            _log = new Mock<IPeninsulaLog>();
            _fireRiskAssessmentRepository = new Mock<IFireRiskAssessmentRepository>();
            _userForAuditingRepository = new Mock<IUserForAuditingRepository>();
            _employeeRepository = new Mock<IEmployeeRepository>();
            _checklistRepository = new Mock<IChecklistRepository>();
            _riskAssessmentRepository = new Mock<IRiskAssessmentRepository>();
            _siteRepository = new Mock<ISiteRepository>();
            _riskAssessorRepository = new Mock<IRiskAssessorRepository>();

            _request = new SaveRiskAssessmentSummaryRequest()
                       {
                           CompanyId = 100,
                           Reference = "Reference",
                           Title = "Title",
                           UserId = Guid.NewGuid(),
                           Id = 200,
                           AssessmentDate = DateTime.Now,
                           RiskAssessorId = 25L,
                           SiteId = 1,
                           PersonAppointed = "My Person Appointed"
                       };

            

            _target = CreateRiskAssessmentService();
        }
        public void Given_FRA_review_when_completed_then_review_is_Completed()
        {
            // Given
            var fra = new FireRiskAssessment();
            var fraReview = new Mock<RiskAssessmentReview>();
            fra.AddReview( fraReview.Object);
            fra.FireRiskAssessmentChecklists.Add(new FireRiskAssessmentChecklist());

            _userRepo.Setup(x => x.GetByIdAndCompanyId(It.IsAny<Guid>(), It.IsAny<long>())).Returns(new User {Id = Guid.NewGuid()});
            _riskAssessmentRepo.Setup(x => x.GetByIdAndCompanyId(It.IsAny<long>(), It.IsAny<long>())).Returns(fra);

            var target = new FireRiskAssessmentService(_riskAssessmentRepo.Object
                                                       , _userForAuditingRepo.Object
                                                       ,  _checklistRepository.Object
                                                       , _questionRepo.Object
                                                       , _documentParameterHelper.Object, _log.Object, null,_userRepo.Object, null, null);


            var request = new CompleteRiskAssessmentReviewRequest {ReviewingUserId = Guid.NewGuid(), ClientId = 123};

            // When
            target.CompleteFireRiskAssessementReview(request);


            // Then
            fraReview.Verify(x => x.Complete(It.IsAny<string>(), It.IsAny<UserForAuditing>()
                                             , It.IsAny<DateTime?>()
                                             , It.IsAny<bool>()
                                             , It.IsAny<IList<CreateDocumentParameters>>(),It.IsAny<User>()));
        }
 private FireRiskAssessmentService CreateRiskAssessmentService()
 {
     var riskAssessmentService = new FireRiskAssessmentService(
         _fireRiskAssessmentRepository.Object, 
         _userForAuditingRepository.Object, 
         _checklistRepository.Object,
         null, null, _log.Object
         , _riskAssessmentRepository.Object,null,_siteRepository.Object, 
         _riskAssessorRepository.Object);
     return riskAssessmentService;
 }
        public void Given_trying_to_update_reference_to_one_that_already_exists_When_Update_Summary_Then_should_throw_correct_error()
        {
            // Given
            var riskAssessment = new FireRiskAssessment();
            _fireRiskAssessmentRepository
                .Setup(x => x.GetByIdAndCompanyId(_request.Id, _request.CompanyId))
                .Returns(riskAssessment);

            _riskAssessmentRepository
                .Setup(x => x.DoesAssessmentExistWithTheSameReference<FireRiskAssessment>(It.IsAny<long>(), It.IsAny<string>(), It.IsAny<long?>()) )
                .Returns(true);

            _target = CreateRiskAssessmentService();
            
            // When
            // Then
            Assert.Throws<ValidationException>(() =>_target.UpdateRiskAssessmentSummary(_request));
;
        }