public void Given_Exisiting_Checklist_When_Completed_Status_Then_Correct_Properties_Are_Set()
        {
            // Given
            var parameters = new CreateUpdateChecklistParameters()
            {
                SiteId = 11,
                ClientId = 22,
                CoveringLetterContent = "coveringLetterContent",
                Status = null
            };

            var checklist = Checklist.Create(parameters);

            var parametersNew = new CreateUpdateChecklistParameters()
            {
                SiteId = 111,
                ClientId = 222,
                CoveringLetterContent = "Content1",
                Status = "Completed",
                CompletedBy = "fullname",
                CompletedOn = DateTime.Now
            };

            // When
            checklist.UpdateChecklistDetails(parametersNew);

            Assert.That(checklist.Status, Is.EqualTo(parametersNew.Status));
            Assert.That(checklist.ChecklistCompletedBy, Is.EqualTo(parametersNew.CompletedBy));
            Assert.That(checklist.ChecklistCompletedOn, Is.EqualTo(parametersNew.CompletedOn));
        }
Пример #2
0
        public void Given_valid_checklist_When_Crete_called_Then_correct_action_plan_returned()
        {
            // Given
            var parameters = new CreateUpdateChecklistParameters()
            {
                Id = Guid.NewGuid(),
                ClientId = 111,
                SiteAddress1 = "1 purple street",
                SiteAddressPostcode = "M1 1AA",
                VisitDate = "13/01/2000",
                Submit = true,
                Site = new Site() { Id = 11L}
            };

           var checklist = Checklist.Create(parameters); 
            
            // When
           // var actionPlan = ActionPlan.Create(checklist);

            // Then
            Assert.That(checklist.ActionPlan.Checklist , Is.EqualTo(checklist));
            Assert.That(checklist.ActionPlan.CompanyId, Is.EqualTo(checklist.ClientId));
            //Assert.That(actionPlan.Title, Is.EqualTo(checklist.));

            //todo: need to load site into checklist
            //Assert.That(actionPlan.Site.SiteId, Is.EqualTo(checklist.SiteId));

            Assert.That(checklist.ActionPlan.DateOfVisit, Is.EqualTo(checklist.VisitDate));
            Assert.That(checklist.ActionPlan.VisitBy, Is.EqualTo(checklist.VisitBy));
            Assert.That(checklist.ActionPlan.SubmittedOn, Is.Not.EqualTo(default(DateTime)));
            Assert.That(checklist.ActionPlan.AreasVisited, Is.EqualTo(checklist.AreasVisited));
            Assert.That(checklist.ActionPlan.AreasNotVisited, Is.EqualTo(checklist.AreasNotVisited));
            Assert.That(checklist.ActionPlan.Title, Is.EqualTo("Visit Report - 1 purple street - M1 1AA - 13/01/2000"));
            Assert.That(checklist.ActionPlan.Site, Is.EqualTo(parameters.Site));
        }
        public void Update_Checklist_Details()
        {
            // Given
            var parameters = new CreateUpdateChecklistParameters()
            {
                SiteId = 11,
                ClientId = 22,
                CoveringLetterContent = "coveringLetterContent",
                Status = "status"
            };

            var checklist = Checklist.Create(parameters);

            var parametersNew = new CreateUpdateChecklistParameters()
            {
                SiteId = 111,
                ClientId = 222,
                CoveringLetterContent = "Content1",
                Status = "Status1"
            };

            // When
            checklist.UpdateChecklistDetails(parametersNew);

            Assert.That(checklist.SiteId, Is.EqualTo(111));
            Assert.That(checklist.ClientId, Is.EqualTo(222));
            Assert.That(checklist.CoveringLetterContent, Is.EqualTo("Content1"));
            Assert.That(checklist.Status, Is.EqualTo("Status1"));
        }
Пример #4
0
        public void Given_valid_checklist_When_Create_called_when_not_submitted_Then_action_plan_is_null()
        {

            // Given
            var parameters = new CreateUpdateChecklistParameters()
            {
                Id = Guid.NewGuid(),
                ClientId = 111,
                SiteAddress1 = "1 purple street",
                SiteAddressPostcode = "M1 1AA",
                VisitDate = "13/01/2000"
            };

            var checklist = Checklist.Create(parameters);
            
            // Then
            Assert.That(checklist.ActionPlan, Is.Null);
        }
        public void When_Create_Then_Return_Checklist()
        {
            // Given
            var parameters = new CreateUpdateChecklistParameters()
            {
                SiteId = 11,
                ClientId = 22,
                CoveringLetterContent = "coveringLetterContent",
                Status = "status",
                Jurisdiction = "UK"
            };


            // When
            var result = Checklist.Create(parameters);

            // Then
            Assert.That(result, Is.InstanceOf<Checklist>());
            Assert.That(result.SiteId, Is.EqualTo(11));
            Assert.That(result.ClientId, Is.EqualTo(22));
            Assert.That(result.CoveringLetterContent, Is.EqualTo("coveringLetterContent"));
            Assert.That(result.Status, Is.EqualTo("status"));
            Assert.That(result.Jurisdiction, Is.EqualTo("UK"));
        }
        public void Given_a_checklist_is_assigned_and_a_consultant_completes_checklist_then_status_stays_assigned()
        {
            var Id = Guid.NewGuid();

            // Given
            var checklist = new Checklist();
            checklist.Status = "Assigned";

            var parameters = new CreateUpdateChecklistParameters()
            {
                Id = Id,
                ClientId = 11,
                SiteId = 22,
                CoveringLetterContent = "Letter content",
                Status = "Completed",
                VisitBy = "VisitBy",
                VisitDate = "10/10/2013",
                VisitType = "Visit Type",
                MainPersonSeenName = "Person Seen Name",
                AreasVisited = "Areas Visited",
                AreasNotVisited = "Areas Not Visited",
                EmailAddress = "email",
                ImpressionType = new ImpressionType() { Comments = "comments" },
                ImmediateRiskNotifications = new List<AddImmediateRiskNotificationParameters>(),
                SubmittedBy = "username",
                SubmittedOn = DateTime.Now,
                Submit = true
            };
          
            checklist.UpdateChecklistDetails(parameters);

            Assert.That(checklist.Status,Is.EqualTo("Assigned"));
        }
        public void Given_A_Checklist_is_submitted_then_submitted_properties_are_set()
        {
            var Id = Guid.NewGuid();

            // Given
            var parameters = new CreateUpdateChecklistParameters()
            {
                Id = Id,
                ClientId = 11,
                SiteId = 22,
                CoveringLetterContent = "Letter content",
                Status = "Status",
                VisitBy = "VisitBy",
                VisitDate = "10/10/2013",
                VisitType = "Visit Type",
                MainPersonSeenName = "Person Seen Name",
                AreasVisited = "Areas Visited",
                AreasNotVisited = "Areas Not Visited",
                EmailAddress = "email",
                ImpressionType = new ImpressionType() { Comments = "comments" },
                ImmediateRiskNotifications = new List<AddImmediateRiskNotificationParameters>(),
                SubmittedBy = "username",
                SubmittedOn = DateTime.Now,
                Submit = true
            };

            // When
            var checklist = Checklist.Create(parameters);

            Assert.That(checklist.ChecklistSubmittedBy, Is.EqualTo(parameters.SubmittedBy));
            Assert.That(checklist.ChecklistSubmittedOn, Is.EqualTo(parameters.SubmittedOn));
        }
        public void Given_A_Checklist_is_submitted_then_exception_thrown_if_submitted_again()
        {
            var Id = Guid.NewGuid();

            // Given
            var parameters = new CreateUpdateChecklistParameters()
            {
                Id = Id,
                ClientId = 11,
                SiteId = 22,
                CoveringLetterContent = "Letter content",
                Status = "Status",
                VisitBy = "VisitBy",
                VisitDate = "10/10/2013",
                VisitType = "Visit Type",
                MainPersonSeenName = "Person Seen Name",
                AreasVisited = "Areas Visited",
                AreasNotVisited = "Areas Not Visited",
                EmailAddress = "email",
                ImpressionType = new ImpressionType() { Comments = "comments" },
                ImmediateRiskNotifications = new List<AddImmediateRiskNotificationParameters>(),
                Submit = true
            };

            var checklist = Checklist.Create(parameters);
            
            var ex = Assert.Throws<SafeCheckChecklistAlreadySubmittedException>(() => checklist.UpdateChecklistDetails(parameters));
        }
        public void Given_A_Checklist_is_submitted_then_action_plan_is_created()
        {
            var Id = Guid.NewGuid();

            // Given
            var parameters = new CreateUpdateChecklistParameters()
            {
                Id = Id,
                ClientId = 11,
                SiteId = 22,
                CoveringLetterContent = "Letter content",
                Status = "Status",
                VisitBy = "VisitBy",
                VisitDate = "10/10/2013",
                VisitType = "Visit Type",
                MainPersonSeenName = "Person Seen Name",
                AreasVisited = "Areas Visited",
                AreasNotVisited = "Areas Not Visited",
                EmailAddress = "email",
                ImpressionType = new ImpressionType() { Comments = "comments" },
                ImmediateRiskNotifications = new List<AddImmediateRiskNotificationParameters>(),
                Submit = true
            };

            // When
            var checklist = Checklist.Create(parameters);

            Assert.That(checklist.ActionPlan, Is.Not.Null);
        }
Пример #10
0
        private CreateUpdateChecklistParameters CreateUpdateChecklistParameters(ChecklistViewModel model,
            UserForAuditing user)
        {
            var createUpdateChecklistParameters = new CreateUpdateChecklistParameters();
            createUpdateChecklistParameters.Id = model.Id;
            createUpdateChecklistParameters.ClientId = model.ClientId;
            createUpdateChecklistParameters.SiteId = model.SiteId;
            createUpdateChecklistParameters.CoveringLetterContent = model.CoveringLetterContent;
            createUpdateChecklistParameters.Status = model.Status;
            createUpdateChecklistParameters.Submit = model.Submit;
            createUpdateChecklistParameters.User = user;
            createUpdateChecklistParameters.Site = _siteRepository.GetByPeninsulaSiteId((long) model.SiteId);

            createUpdateChecklistParameters.CreatedOn = model.CreatedOn;
            createUpdateChecklistParameters.CreatedBy = model.CreatedBy;
            createUpdateChecklistParameters.CompletedOn = model.CompletedOn;
            createUpdateChecklistParameters.CompletedBy = model.CompletedBy;
            createUpdateChecklistParameters.SubmittedOn = model.SubmittedOn;
            createUpdateChecklistParameters.SubmittedBy = model.SubmittedBy;
            createUpdateChecklistParameters.PostedBy = model.PostedBy;
            createUpdateChecklistParameters.Industry = model.IndustryId.HasValue ? _industryRepository.LoadById(model.IndustryId.Value): null;
		    createUpdateChecklistParameters.QAComments = model.QAComments;
		    createUpdateChecklistParameters.LastModifiedOn = model.LastModifiedOn;
            createUpdateChecklistParameters.EmailReportToPerson = model.EmailReportToPerson.HasValue && model.EmailReportToPerson.Value;
            createUpdateChecklistParameters.EmailReportToOthers = model.EmailReportToOthers.HasValue && model.EmailReportToOthers.Value;
            createUpdateChecklistParameters.PostReport = model.PostReport.HasValue && model.PostReport.Value;
		    createUpdateChecklistParameters.OtherEmailAddresses = model.OtherEmailAddresses;

            if (model.SiteVisit != null)
            {
                createUpdateChecklistParameters.VisitDate = model.SiteVisit.VisitDate;
                createUpdateChecklistParameters.VisitBy = model.SiteVisit.VisitBy;
                createUpdateChecklistParameters.VisitType = model.SiteVisit.VisitType;

                if (model.SiteVisit.PersonSeen != null)
                {
                    createUpdateChecklistParameters.PersonSeenJobTitle = model.SiteVisit.PersonSeen.JobTitle;
                    createUpdateChecklistParameters.PersonSeenName = model.SiteVisit.PersonSeen.Name;
                    createUpdateChecklistParameters.PersonSeenSalutation = model.SiteVisit.PersonSeen.Salutation;
                    createUpdateChecklistParameters.PersonSeenId = model.SiteVisit.PersonSeen.Id;
                }

                createUpdateChecklistParameters.AreasNotVisited = model.SiteVisit.AreasNotVisited;
                createUpdateChecklistParameters.AreasVisited = model.SiteVisit.AreasVisited;
                createUpdateChecklistParameters.EmailAddress = model.SiteVisit.EmailAddress;


                createUpdateChecklistParameters.ImpressionType = (model.SiteVisit.SelectedImpressionType == null ||
                                                                  model.SiteVisit.SelectedImpressionType.Id ==
                                                                  Guid.Empty)
                    ? null
                    : _impressionRespository.GetById(
                        model.SiteVisit.SelectedImpressionType.Id);

                createUpdateChecklistParameters.SiteAddress1 = model.Site == null ? String.Empty : model.Site.Address1;
                createUpdateChecklistParameters.SiteAddressPostcode = model.Site == null
                    ? String.Empty
                    : model.Site.Postcode;
            }

            foreach (var immediateRiskNotificationViewModel in model.ImmediateRiskNotifications)
            {
                // This part updates the IRN's for storage on the checklist, retrieved in SafeCheck when not submitted
                createUpdateChecklistParameters.ImmediateRiskNotifications.Add(new AddImmediateRiskNotificationParameters
                {
                    Id = immediateRiskNotificationViewModel.Id,
                    Reference = immediateRiskNotificationViewModel.Reference,
                    Title = immediateRiskNotificationViewModel.Title,
                    SignificantHazardIdentified = immediateRiskNotificationViewModel.SignificantHazard,
                    RecommendedImmediateAction = immediateRiskNotificationViewModel.RecommendedImmediate
                });
            }
            return createUpdateChecklistParameters;
        }
Пример #11
0
        public void Given_valid_checklist_When_CreateImmediateRiskNotifications_called_when_submitted_Then_Actions_Populated()
        {
            // Given
            var parameters = new CreateUpdateChecklistParameters()
            {
                Id = Guid.NewGuid(),
                ClientId = 111,
                SiteAddress1 = "1 purple street",
                SiteAddressPostcode = "M1 1AA",
                VisitDate = "13/01/2000",
                ImmediateRiskNotifications = new List<AddImmediateRiskNotificationParameters>(),
                CompletedBy = "CompletedBy",
                CompletedOn = DateTime.Now,
                Submit = true,
                MainPersonSeen = new Employee {Id = Guid.NewGuid()}
            };

            parameters.ImmediateRiskNotifications.Add(new AddImmediateRiskNotificationParameters()
            {
                Id = Guid.NewGuid(), 
                RecommendedImmediateAction = "Action 1",
                Reference = "Ref 1", 
                SignificantHazardIdentified = "Hazard 1", 
                Title = "Title 1",
            });

            parameters.ImmediateRiskNotifications.Add(new AddImmediateRiskNotificationParameters()
            {
                Id = Guid.NewGuid(),
                RecommendedImmediateAction = "Action 2",
                Reference = "Ref 2",
                SignificantHazardIdentified = "Hazard 2",
                Title = "Title 2"
            });

            var checklist = Checklist.Create(parameters);
            checklist.ActionPlan.CreateImmediateRiskNotifications();

            // Then
            Assert.That(checklist.ActionPlan, Is.Not.Null);
            Assert.That(checklist.ActionPlan.Actions.Count(), Is.EqualTo(2));
            Assert.That(checklist.ActionPlan.Actions.ElementAt(0).Title, Is.EqualTo(parameters.ImmediateRiskNotifications.ElementAt(0).Title));
            Assert.That(checklist.ActionPlan.Actions.ElementAt(1).Title, Is.EqualTo(parameters.ImmediateRiskNotifications.ElementAt(1).Title));
            Assert.That(checklist.ActionPlan.Actions.ElementAt(1).Reference, Is.EqualTo(parameters.ImmediateRiskNotifications.ElementAt(1).Reference));

            Assert.That(checklist.ActionPlan.Actions.ElementAt(0).AssignedTo.Id, Is.EqualTo(parameters.MainPersonSeen.Id));
            Assert.That(checklist.ActionPlan.Actions.ElementAt(1).AssignedTo.Id, Is.EqualTo(parameters.MainPersonSeen.Id));
        }
Пример #12
0
        private CreateUpdateChecklistParameters CreateUpdateChecklistParameters(ChecklistViewModel model,
            UserForAuditing user)
        {
            var parameters = new CreateUpdateChecklistParameters();

            parameters.Id = model.Id;
            parameters.ClientId = model.ClientId;
            parameters.SiteId = model.SiteId;
            parameters.CoveringLetterContent = model.CoveringLetterContent;
            parameters.Status = model.Status;
            parameters.Submit = model.Submit;
            parameters.User = user;
            parameters.Site = _siteRepository.GetByPeninsulaSiteId((long) model.SiteId);

            parameters.CreatedOn = model.CreatedOn;
            parameters.CreatedBy = model.CreatedBy;
            parameters.CompletedOn = model.CompletedOn.ToLocalTime();
            parameters.CompletedBy = model.CompletedBy;
            parameters.SubmittedOn = model.SubmittedOn.ToLocalTime();
            parameters.SubmittedBy = model.SubmittedBy;
            parameters.PostedBy = model.PostedBy;
            parameters.ChecklistTemplate = model.IndustryId.HasValue
                ? _industryRepository.LoadById(model.IndustryId.Value)
                : null;
            parameters.QAComments = model.QAComments;
            parameters.LastModifiedOn = model.LastModifiedOn.ToLocalTime();
            parameters.EmailReportToPerson = model.EmailReportToPerson.HasValue && model.EmailReportToPerson.Value;
            parameters.EmailReportToOthers = model.EmailReportToOthers.HasValue && model.EmailReportToOthers.Value;
            parameters.PostReport = model.PostReport.HasValue && model.PostReport.Value;
            parameters.OtherEmailAddresses = model.OtherEmailAddresses;
            parameters.ReportHeader = string.IsNullOrEmpty(model.ReportHeaderType)
                ? SummaryReportHeaderType.None
                : (SummaryReportHeaderType)
                    Enum.Parse(typeof (SummaryReportHeaderType), model.ReportHeaderType);

            // SGG: Comment out until we support the functionality
            //parameters.IncludeActionPlan = model.IncludeActionPlan;
            //parameters.IncludeComplianceReview = model.IncludeComplianceReview;

            parameters.IncludeActionPlan = true;
            parameters.IncludeComplianceReview = true;

            //parameters.Deleted = model.Deleted;
            //parameters.DeletedBy = model.DeletedBy;
            //parameters.DeletedOn = model.DeletedOn;

            parameters.ExecutiveSummaryUpdateRequired = model.ExecutiveSummaryUpdateRequired;
            parameters.ExecutiveSummaryQACommentsResolved = model.ExecutiveSummaryQACommentsResolved;
            parameters.ExecutiveSummaryQACommentsSignedOffBy = model.ExecutiveSummaryQASignedOffBy;
            parameters.ExecutiveSummaryQACommentsSignedOffDate = model.ExecutiveSummaryQASignedOffDate.ToLocalTime();

            parameters.ClientLogoFilename = model.ClientLogoFilename;
            parameters.ClientSiteGeneralNotes = model.ClientSiteGeneralNotes;
            parameters.SpecialReport = model.SpecialReport;

            if (model.SiteVisit != null)
            {
                parameters.VisitDate = model.SiteVisit.VisitDate.HasValue
                    ? model.SiteVisit.VisitDate.Value.ToLocalTime().ToString("dd/MM/yyyy")
                    : null;
                parameters.VisitBy = model.SiteVisit.VisitBy;
                parameters.VisitType = model.SiteVisit.VisitType;

                if (model.SiteVisit.PersonSeen != null)
                {
                    if (model.SiteVisit.PersonSeen.Id == null)
                    {
                        parameters.MainPersonSeen = null;
                        parameters.MainPersonSeenName = null;
                    }
                    else if (model.SiteVisit.PersonSeen.Id == Guid.Empty)
                    {
                        parameters.MainPersonSeen = null;
                        parameters.MainPersonSeenName = model.SiteVisit.PersonSeen.Name;
                    }
                    else
                    {
                        var employee = _employeeRespository.GetById(model.SiteVisit.PersonSeen.Id.Value);
                        parameters.MainPersonSeen = employee ?? null;
                        parameters.MainPersonSeenName = model.SiteVisit.PersonSeen.Name;
                    }
                }

                parameters.AreasNotVisited = model.SiteVisit.AreasNotVisited;
                parameters.AreasVisited = model.SiteVisit.AreasVisited;
                parameters.EmailAddress = model.SiteVisit.EmailAddress;
                parameters.Jurisdiction = model.Jurisdiction;

                parameters.ImpressionType = (model.SiteVisit.SelectedImpressionType == null ||
                                             model.SiteVisit.SelectedImpressionType.Id ==
                                             Guid.Empty)
                    ? null
                    : _impressionRespository.GetById(
                        model.SiteVisit.SelectedImpressionType.Id);

                parameters.SiteAddress1 = model.Site == null ? String.Empty : model.Site.Address1;
                parameters.SiteAddressPostcode = model.Site == null
                    ? String.Empty
                    : model.Site.Postcode;
            }

            foreach (var immediateRiskNotificationViewModel in model.ImmediateRiskNotifications)
            {
                // This part updates the IRN's for storage on the checklist, retrieved in SafeCheck when not submitted
                parameters.ImmediateRiskNotifications.Add(new AddImmediateRiskNotificationParameters
                {
                    Id = immediateRiskNotificationViewModel.Id,
                    Reference = immediateRiskNotificationViewModel.Reference,
                    Title = immediateRiskNotificationViewModel.Title,
                    SignificantHazardIdentified = immediateRiskNotificationViewModel.SignificantHazard,
                    RecommendedImmediateAction = immediateRiskNotificationViewModel.RecommendedImmediate
                });
            }
            return parameters;
        }