Пример #1
0
 public static void CopySectionsFrom(ChangeOfCircs form, CocDetail detail, bool useExisting = false)
 {
     detail.Consent            = form.Consent;
     detail.Identity           = form.UserId;
     detail.Options            = form.Options;
     detail.ApplicantDetails   = useExisting ? form.ExistingApplicantDetails : form.ApplicantDetails;
     detail.ExpectedChildren   = form.ExpectedChildren;
     detail.HealthProfessional = form.HealthProfessional;
     detail.PaymentDetails     = useExisting ? form.ExistingPaymentDetails : form.PaymentDetails;
     detail.Evidence           = form.Evidence;
     detail.Declaration        = form.Declaration;
 }
Пример #2
0
        protected static CocDetail NewCocDetail(string formId)
        {
            var detail = new CocDetail
            {
                Id = formId,

                Consent            = ConsentBuilder.NewValid(),
                Identity           = "*****@*****.**",
                Options            = OptionsBuilder.NewValid(),
                ApplicantDetails   = ApplicantDetailsBuilder.NewValid(),
                ExpectedChildren   = ExpectedChildrenBuilder.NewValid(),
                HealthProfessional = HealthProfessionalBuilder.NewValid(),
                PaymentDetails     = PaymentDetailsBuilder.NewValid(),
                Evidence           = EvidenceBuilder.NewValid(),
                Declaration        = DeclarationBuilder.NewValid(),
            };

            return(detail);
        }
Пример #3
0
        public CocDetail FindSection(Sections section)
        {
            var detail = new CocDetail
            {
                Consent            = Consent,
                Identity           = UserId,
                Options            = Options,
                ApplicantDetails   = ApplicantDetails ?? ExistingApplicantDetails,
                ExpectedChildren   = ExpectedChildren,
                HealthProfessional = HealthProfessional,
                PaymentDetails     = PaymentDetails ?? ExistingPaymentDetails,
                Evidence           = Evidence,
                Declaration        = Declaration,
            };

            Navigation.Populate(detail, section, this);

            return(detail);
        }
Пример #4
0
        public void Find_PopulatesExistingDetail_IfCurrentDetailDoesNotExist()
        {
            var existingForm = new ChangeOfCircsBuilder("form123")
                               .WithCompletedSections(excludeOptionalSections: true)
                               .Insert();

            var query = new FindCocSection
            {
                FormId  = "form123",
                Section = Sections.Consent,
            };

            var details = query.Find();

            var expectedDetail = new CocDetail {
                PreviousSection = null
            };

            ChangeOfCircsBuilder.CopySectionsFrom(existingForm, expectedDetail, useExisting: true);

            details.ShouldBeEquivalentTo(expectedDetail);
        }
Пример #5
0
        public void Find_PopulatesDetail()
        {
            var existingForm = new ChangeOfCircsBuilder("form123")
                               .WithCompletedSections(markAsCompleted: false)
                               .Insert();

            var query = new FindCocSection
            {
                FormId  = "form123",
                Section = Sections.Consent,
            };

            var detail = query.Find();

            var expectedDetail = new CocDetail {
                PreviousSection = null
            };

            ChangeOfCircsBuilder.CopySectionsFrom(existingForm, expectedDetail);

            detail.ShouldBeEquivalentTo(expectedDetail);
        }
Пример #6
0
        public static void Populate(CocDetail detail, Sections section, ChangeOfCircs form)
        {
            var index = _order.IndexOf(section) - 1;

            while (index >= 0 && !detail.PreviousSection.HasValue)
            {
                var previousSection = _order[index];

                if (!FeatureToggles.SkipWorkInProgressSection(previousSection))
                {
                    var strategy = SectionStrategy.For(previousSection);

                    if (strategy.Required(form))
                    {
                        detail.PreviousSection = previousSection;
                    }
                }

                index--;
            }

            detail.IsFinalSection = (section == _order.Last());
        }