public void Given_no_further_control_measure_tasks_and_no_review_tasks_then_CompletionDueDate_is_null()
      {
          //given
          var riskAss = new FireRiskAssessment();
 
          Assert.IsNull(riskAss.CompletionDueDate);
      }
        public void Given_FRA_review_when_completed_then_FRA_is_saved()
        {
            // 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
            _riskAssessmentRepo.Verify(x => x.SaveOrUpdate(fra), Times.Once());
        }
 public void SetUp()
 {
     _clientId = 3423L;
     _currentUser = new UserForAuditing { Id = Guid.NewGuid() };
     _checklist = new Checklist {Id = 42L};
     _fireRiskAssessment = FireRiskAssessment.Create(
         "Fire Risk Assessment 2", "GRA02", _clientId, _checklist, _currentUser);
 }
        public void Given_no_further_control_measure_tasks_and_1_review_tasks_then_CompletionDueDate_is_next_review_date()
        {
            var riskAss = new FireRiskAssessment();
            var reviewTask = new RiskAssessmentReview() {CompletionDueDate = new DateTime(2013, 5, 7)};
            
            riskAss.AddReview(reviewTask);

            Assert.AreEqual(reviewTask.CompletionDueDate, riskAss.CompletionDueDate.Value);
        }
 public FireRiskAssessmentDto MapWithEverything(FireRiskAssessment entity)
 {
     var dto = new RiskAssessmentDtoMapper().MapWithEmployeesAndNonEmployeesAndSiteAndRiskAssessor(entity) as FireRiskAssessmentDto;
     dto.PeopleAtRisk = PeopleAtRiskDtoMapper.Map(entity.PeopleAtRisk.Select(x => x.PeopleAtRisk).ToList());
     dto.FireSafetyControlMeasures = new FireRiskAssessmentControlMeasureDtoMapper().MapWithControlMeasure(entity.FireSafetyControlMeasures);
     dto.FireRiskAssessmentSourcesOfFuel = new FireRiskAssessmentSourceOfFuelDtoMapper().MapWithSourceOfFuel(entity.FireRiskAssessmentSourcesOfFuel);
     dto.FireRiskAssessmentSourcesOfIgnition = new FireRiskAssessmentSourceOfIgnitionDtoMapper().MapWithSourceOfIgnition(entity.FireRiskAssessmentSourcesOfIgnition);
     dto.LatestFireRiskAssessmentChecklist = new FireRiskAssessmentChecklistDtoMapper().MapWithChecklist(entity.LatestFireRiskAssessmentChecklist);
     dto.SignificantFindings = new SignificantFindingsDtoMapper().Map(entity.LatestFireRiskAssessmentChecklist.SignificantFindings.Where(x => x.Deleted == false).ToList());
     return dto;
 }
        public void Given_Firechecklist_is_emptylist_When_retrieving_LatestFireRiskAssessmentChecklist_then_return_null()
        {
            //Given
            var fireRa = new FireRiskAssessment();
            fireRa.FireRiskAssessmentChecklists = new List<FireRiskAssessmentChecklist>();

            //When
            var result = fireRa.LatestFireRiskAssessmentChecklist;

            //Then
            Assert.IsNull(result);
        }
        public FireRiskAssessmentDto MapWithFireSafetyControlMeasuresAndPeopleAtRiskAndSourcesOfFuelAndSourcesOfIgnition(FireRiskAssessment entity)
        {
            var dto = new RiskAssessmentDtoMapper().MapWithEmployeesAndNonEmployeesAndSiteAndRiskAssessor(entity) as FireRiskAssessmentDto;

            //TODO: PTD - map this properly
            dto.PeopleAtRisk = PeopleAtRiskDtoMapper.Map(entity.PeopleAtRisk.Select(x => x.PeopleAtRisk).ToList());

            dto.FireSafetyControlMeasures = new FireRiskAssessmentControlMeasureDtoMapper().MapWithControlMeasure(entity.FireSafetyControlMeasures);
            dto.FireRiskAssessmentSourcesOfFuel = new FireRiskAssessmentSourceOfFuelDtoMapper().MapWithSourceOfFuel(entity.FireRiskAssessmentSourcesOfFuel);
            dto.FireRiskAssessmentSourcesOfIgnition = new FireRiskAssessmentSourceOfIgnitionDtoMapper().MapWithSourceOfIgnition(entity.FireRiskAssessmentSourcesOfIgnition);
            return dto;
        }
        private static FireRiskAssessmentFurtherControlMeasureTask CreateFireRiskAssessmentFurtherControlMeasureTask()
        {
            var fireRiskAssessment = new FireRiskAssessment();
            var fireRiskAssessmentChecklist = new FireRiskAssessmentChecklist();
            fireRiskAssessmentChecklist.FireRiskAssessment = fireRiskAssessment;

            var fireAnswer = new FireAnswer();
            fireAnswer.FireRiskAssessmentChecklist = fireRiskAssessmentChecklist;
            fireRiskAssessmentChecklist.Answers.Add(fireAnswer);

            var significantFinding = SignificantFinding.Create(fireAnswer, null);
            var fraTask = new FireRiskAssessmentFurtherControlMeasureTask();
            fraTask.SignificantFinding = significantFinding;
            return fraTask;
        }
        public void Given_all_required_felds_are_available_When_UpdatePremisesInformation_Then_Values_Updated()
        {
            //Given
            const bool premisesProvidesSleepingAccommodation = true;
            const bool premisesProvidesSleepingAccommodationConfirmed = true;
            string buildinguse = "building use";
            string location = "location";
            int numberOfFloors = 5;
            int numberOfPeople = 600;
            string electricityEmergencyShutOff = "Elect shutoff";
            string waterEmergencyShutOff = "Water shutoff";
            string gasEmergencyShutOff = "Gas Shutoff";
            string otherEmergencyShutOff = "other Shutoff";
            var user = new UserForAuditing();
            var result = new FireRiskAssessment();

            //When
            result.UpdatePremisesInformation(premisesProvidesSleepingAccommodation,
                                             premisesProvidesSleepingAccommodationConfirmed, 
                                             location, 
                                             buildinguse, 
                                             numberOfFloors, 
                                             numberOfPeople, 
                                             new EmergencyShutOffParameters()
                                                {
                                                    ElectricityEmergencyShutOff = electricityEmergencyShutOff,
                                                    WaterEmergencyShutOff = waterEmergencyShutOff,
                                                    GasEmergencyShutOff = gasEmergencyShutOff,
                                                    OtherEmergencyShutOff = otherEmergencyShutOff
                                                }, 
                                             user);

            //Then
            Assert.That(result.PremisesProvidesSleepingAccommodation, Is.EqualTo(premisesProvidesSleepingAccommodation));
            Assert.That(result.PremisesProvidesSleepingAccommodationConfirmed, Is.EqualTo(premisesProvidesSleepingAccommodationConfirmed));
            Assert.That(result.Location, Is.EqualTo(location));
            Assert.That(result.BuildingUse, Is.EqualTo(buildinguse));
            Assert.That(result.NumberOfFloors, Is.EqualTo(numberOfFloors));
            Assert.That(result.NumberOfPeople, Is.EqualTo(numberOfPeople));
            Assert.That(result.ElectricityEmergencyShutOff, Is.EqualTo(electricityEmergencyShutOff));
            Assert.That(result.WaterEmergencyShutOff, Is.EqualTo(waterEmergencyShutOff));
            Assert.That(result.GasEmergencyShutOff, Is.EqualTo(gasEmergencyShutOff));
            Assert.That(result.OtherEmergencyShutOff, Is.EqualTo(otherEmergencyShutOff));
            Assert.That(result.LastModifiedBy, Is.EqualTo(user));
            Assert.That(result.LastModifiedOn.Value.Date, Is.EqualTo(DateTime.Today));
        }
Esempio n. 10
0
        public void TestFixtureSetUp()
        {
            _fireRiskAssessment = FireRiskAssessment.Create("Test Title", "REF01", 213123L, null, _currentUser);

            var answerParameterClasses = new List<SubmitFireAnswerParameters>
                                             {
                                                 new SubmitFireAnswerParameters
                                                     {
                                                         Question = new Question
                                                                        {
                                                                            Id = 1001L
                                                                        },
                                                         YesNoNotApplicableResponse = YesNoNotApplicableEnum.Yes,
                                                         AdditionalInfo = "some more stuff"
                                                     },
                                                 new SubmitFireAnswerParameters
                                                     {
                                                         Question = new Question
                                                                        {
                                                                            Id = 1002L
                                                                        },
                                                         YesNoNotApplicableResponse = YesNoNotApplicableEnum.No
                                                     },
                                                 new SubmitFireAnswerParameters
                                                     {
                                                         Question = new Question
                                                                        {
                                                                            Id = 1003L
                                                                        },
                                                         YesNoNotApplicableResponse = YesNoNotApplicableEnum.No
                                                     },
                                                 new SubmitFireAnswerParameters
                                                     {
                                                         Question = new Question
                                                                        {
                                                                            Id = 1004L
                                                                        },
                                                         YesNoNotApplicableResponse =
                                                             YesNoNotApplicableEnum.NotApplicable
                                                     }
                                             };

            _fireRiskAssessment.CompleteFireRiskAssessmentChecklist(answerParameterClasses, _currentUser);
        }
        public void Given_a_further_control_measure_task_is_completed_and_no_review_tasks_then_CompletionDueDate_is_null()
        {
            //given
            var nextFCMCompletionDueDate = new DateTime(2013, 5, 7);
            var riskAss = new FireRiskAssessment();

            var finding = new SignificantFinding();
            finding.AddFurtherControlMeasureTask(new FireRiskAssessmentFurtherControlMeasureTask() { TaskCompletionDueDate = nextFCMCompletionDueDate, TaskStatus = TaskStatus.Completed}, null);

            var findingList = new List<SignificantFinding>();
            findingList.Add((finding));

            var fireChecklist = new Mock<FireRiskAssessmentChecklist>() { CallBase = true };
            fireChecklist.Setup(x => x.SignificantFindings).Returns(findingList);

            riskAss.FireRiskAssessmentChecklists.Add(fireChecklist.Object);

            Assert.IsNull(riskAss.CompletionDueDate);
        }
        public void When_CreateRiskAssessment_Then_New_RiskAssessment_Id_Is_Returned()
        {
            // Given
            var request = new CreateRiskAssessmentRequest()
            {
                UserId = Guid.NewGuid(),
                Title = "Title",
                Reference = "Reference",
                CompanyId = 100
            };

            var passedFireRiskAssessment = new FireRiskAssessment();

            _fireRiskAssessmentRepo
                .Setup(x => x.Save(It.IsAny<FireRiskAssessment>()))
                .Callback<FireRiskAssessment>(y => passedFireRiskAssessment = y);

            var target = GetTarget();

            // When
            var result = target.CreateRiskAssessment(request);

            // Then
            Assert.That(result, Is.EqualTo(passedFireRiskAssessment.Id));
        }
        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));
;
        }
        public void Given_a_significant_finding_but_no_further_control_measure_task_is_not_required_and_no_review_tasks_then_CompletionDueDate_is_null()
        {
            //given
            var riskAss = new FireRiskAssessment();
            var findingList = new List<SignificantFinding> {new SignificantFinding()};

            var fireChecklist = new Mock<FireRiskAssessmentChecklist>() { CallBase = true };
            fireChecklist.Setup(x => x.SignificantFindings).Returns(findingList);

            riskAss.FireRiskAssessmentChecklists.Add(fireChecklist.Object);

            Assert.IsNull(riskAss.CompletionDueDate);
        }
 public FireRiskAssessmentDto MapWithSignificantFindings(FireRiskAssessment entity)
 {
     var dto = new RiskAssessmentDtoMapper().MapWithEmployeesAndNonEmployeesAndSiteAndRiskAssessor(entity) as FireRiskAssessmentDto;
     dto.SignificantFindings = new SignificantFindingsDtoMapper().Map(entity.LatestFireRiskAssessmentChecklist.SignificantFindings.Where(x => x.Deleted == false).ToList());
     return dto;
 }
 public FireRiskAssessmentDto MapWithLatestFireRiskAssessmentChecklist(FireRiskAssessment entity)
 {
     var dto = new RiskAssessmentDtoMapper().MapWithEmployeesAndNonEmployeesAndSiteAndRiskAssessor(entity) as FireRiskAssessmentDto;
     dto.LatestFireRiskAssessmentChecklist = new FireRiskAssessmentChecklistDtoMapper().MapWithChecklist(entity.LatestFireRiskAssessmentChecklist);
     return dto;
 }
        public void When_CreateRiskAssessment_Then_Pass_Populated_RiskAssessment_To_Repo_To_Save()
        {
            // Given
            var request = new CreateRiskAssessmentRequest()
            {
                UserId = Guid.NewGuid(),
                Title = "Title",
                Reference = "Reference",
                CompanyId = 100
            };

            _userRepo
                .Setup(x => x.GetByIdAndCompanyId(It.IsAny<Guid>(), It.IsAny<long>()))
                .Returns(new UserForAuditing()
                {
                    Id = request.UserId
                });

            var passedFireRiskAssessment = new FireRiskAssessment();

            _fireRiskAssessmentRepo
                .Setup(x => x.Save(It.IsAny<FireRiskAssessment>()))
                .Callback<FireRiskAssessment>(y => passedFireRiskAssessment = y);

            var target = GetTarget();

            // When
            target.CreateRiskAssessment(request);

            // Then
            _fireRiskAssessmentRepo.Verify(x => x.Save(It.IsAny<FireRiskAssessment>()));
            Assert.That(passedFireRiskAssessment.Title, Is.EqualTo(request.Title));
            Assert.That(passedFireRiskAssessment.Reference, Is.EqualTo(request.Reference));
            Assert.That(passedFireRiskAssessment.CompanyId, Is.EqualTo(request.CompanyId));
            Assert.That(passedFireRiskAssessment.CreatedBy.Id, Is.EqualTo(request.UserId));
        }
        public static FireRiskAssessment Create(string title, string reference, long companyId, Checklist checklist, UserForAuditing currentUser)
        {
            var now = DateTime.Now;

            var fireRiskAssessment = new FireRiskAssessment
            {
                CompanyId = companyId,
                Reference = reference,
                Title = title,
                CreatedBy = currentUser,
                CreatedOn = now,
                Status = RiskAssessmentStatus.Draft
            };

            var fireRiskAssessmentChecklist = new FireRiskAssessmentChecklist
                                                  {
                                                      Checklist = checklist,
                                                      FireRiskAssessment = fireRiskAssessment,
                                                      CreatedBy = currentUser,
                                                      CreatedOn = now
                                                  };

            fireRiskAssessment.FireRiskAssessmentChecklists.Add(fireRiskAssessmentChecklist);
            return fireRiskAssessment;
        }
 public FireRiskAssessmentDto Map(FireRiskAssessment entity)
 {
     var dto = new RiskAssessmentDtoMapper().MapWithEmployeesAndNonEmployeesAndSiteAndRiskAssessor(entity) as FireRiskAssessmentDto;
     return dto;
 }
        public void Given_a_further_control_measure_task_is_attached_to_a_deleted_significant_finding_and_no_review_tasks_then_CompletionDueDate_is_null()
        {
            //given
            var riskAss = new FireRiskAssessment();
            var finding = new SignificantFinding();
            finding.Deleted = true;
            finding.AddFurtherControlMeasureTask(new FireRiskAssessmentFurtherControlMeasureTask() { TaskCompletionDueDate = DateTime.Now}, null);

            var findingList = new List<SignificantFinding> {(finding)};

            var fireChecklist = new Mock<FireRiskAssessmentChecklist>() { CallBase = true };
            fireChecklist.Setup(x => x.SignificantFindings).Returns(findingList);

            riskAss.FireRiskAssessmentChecklists.Add(fireChecklist.Object);

            Assert.IsNull(riskAss.CompletionDueDate);
        }