protected static BsgDetail NewBsgDetail(string formId, int childCount = 2)
        {
            var detail = new BsgDetail
            {
                Id = formId,

                Consent                 = ConsentBuilder.NewValid(),
                ApplicantDetails        = ApplicantDetailsBuilder.NewValid(),
                ExpectedChildren        = ExpectedChildrenBuilder.NewValid(),
                ExistingChildren        = ExistingChildrenBuilder.NewValid(childCount),
                ApplicantBenefits       = BenefitsBuilder.NewWithBenefit(),
                PartnerBenefits         = BenefitsBuilder.NewWithBenefit(),
                GuardianBenefits        = BenefitsBuilder.NewWithBenefit(),
                GuardianPartnerBenefits = BenefitsBuilder.NewWithBenefit(),
                PartnerDetails          = RelationDetailsBuilder.NewValid("partner"),
                GuardianDetails         = RelationDetailsBuilder.NewValid("guardian"),
                GuardianPartnerDetails  = RelationDetailsBuilder.NewValid("guardian partner"),
                HealthProfessional      = HealthProfessionalBuilder.NewValid(),
                PaymentDetails          = PaymentDetailsBuilder.NewValid(),
                Evidence                = EvidenceBuilder.NewValid(),
                Declaration             = DeclarationBuilder.NewValid(),
            };

            return(detail);
        }
예제 #2
0
        public BestStartGrantBuilder WithCompletedSections(bool markAsCompleted = true)
        {
            With(f => f.Consent, ConsentBuilder.NewValid());
            With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid());
            With(f => f.ExpectedChildren, ExpectedChildrenBuilder.NewValid());
            With(f => f.ExistingChildren, ExistingChildrenBuilder.NewValid());
            With(f => f.ApplicantBenefits, BenefitsBuilder.NewWithBenefit());
            With(f => f.PartnerBenefits, BenefitsBuilder.NewWithBenefit());
            With(f => f.GuardianBenefits, BenefitsBuilder.NewWithBenefit());
            With(f => f.GuardianPartnerBenefits, BenefitsBuilder.NewWithBenefit());
            With(f => f.PartnerDetails, RelationDetailsBuilder.NewValid("partner"));
            With(f => f.GuardianDetails, RelationDetailsBuilder.NewValid("guardian"));
            With(f => f.GuardianPartnerDetails, RelationDetailsBuilder.NewValid("guardian partner"));
            With(f => f.HealthProfessional, HealthProfessionalBuilder.NewValid());
            With(f => f.PaymentDetails, PaymentDetailsBuilder.NewValid());
            With(f => f.Evidence, EvidenceBuilder.NewValid());
            With(f => f.Declaration, DeclarationBuilder.NewValid());

            With(f => f.Started, DomainRegistry.NowUtc() - TimeSpan.FromHours(24));
            With(f => f.Completed, DomainRegistry.NowUtc());
            With(f => f.UserId, _instance.ApplicantDetails?.EmailAddress);
            VerifyConsistent(_instance);

            if (!markAsCompleted)
            {
                With(f => f.Completed, null);
            }

            return(this);
        }
 private NextSection AddExistingChildren(NextSection current, int childCount = 2, Action <ExistingChildren> mutator = null)
 {
     current.Section.Should().Be(Sections.ExistingChildren);
     return(NextSection(current.Section, () => new AddExistingChildren {
         FormId = current.Id, ExistingChildren = ExistingChildrenBuilder.NewValid(childCount, mutator)
     }.Execute()));
 }
        public void NextSectionClearsSkippedSections()
        {
            var form = new BestStartGrantBuilder("form")
                       .With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid(ad => ad.Under16(TestNowUtc.Value)))
                       .With(f => f.ApplicantBenefits, BenefitsBuilder.NewWithBenefit())
                       .With(f => f.Declaration, DeclarationBuilder.NewValid())
                       .Insert();

            form.AddExistingChildren(ExistingChildrenBuilder.NewValid());

            form = Repository.Load <BestStartGrant>(form.Id);

            form.Declaration.Should().NotBeNull("should not be overwritten by moving to the next section");
            form.ApplicantBenefits.Should().BeNull("intermediate 'ApplicantBenefits' section should be cleared based on answers");
        }
예제 #5
0
        public void Execute_StoresExistingDetails()
        {
            var existingForm = new BestStartGrantBuilder("form123")
                               .With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid())
                               .With(f => f.ExpectedChildren, ExpectedChildrenBuilder.NewValid())
                               .Insert();

            existingForm.ExistingChildren.Should().BeNull("no data stored before executing command");

            var cmd = new AddExistingChildren
            {
                FormId           = "form123",
                ExistingChildren = ExistingChildrenBuilder.NewValid(),
            };

            cmd.Execute();

            var updatedForm = Repository.Load <BestStartGrant>("form123");

            updatedForm.ExistingChildren.Should().NotBeNull();
            updatedForm.ExistingChildren.Children.Count.Should().Be(cmd.ExistingChildren.Children.Count);
        }
예제 #6
0
        public void Execute_StoresPaymentDetails()
        {
            var existingForm = new BestStartGrantBuilder("form123")
                               .With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid())
                               .With(f => f.ExpectedChildren, ExpectedChildrenBuilder.NewValid())
                               .With(f => f.ExistingChildren, ExistingChildrenBuilder.NewValid())
                               .With(f => f.HealthProfessional, HealthProfessionalBuilder.NewValid())
                               .Insert();

            existingForm.PaymentDetails.Should().BeNull("no data stored before executing command");

            var cmd = new AddPaymentDetails
            {
                FormId         = "form123",
                PaymentDetails = PaymentDetailsBuilder.NewValid(),
            };

            cmd.Execute();

            var updatedForm = Repository.Load <BestStartGrant>("form123");

            updatedForm.PaymentDetails.Should().NotBeNull();
            updatedForm.PaymentDetails.AccountNumber.Should().Be(cmd.PaymentDetails.AccountNumber);
        }
        public void RequiresApplicantBenefits_NotRequiredWhenAllChildrenKinshipCare()
        {
            var form = new BestStartGrantBuilder("form")
                       .With(f => f.ExistingChildren, ExistingChildrenBuilder.NewValid(0))
                       .Value();

            Navigation.RequiresApplicantBenefits(form).Should().BeTrue("should ask for applicant benefits if no existing children with kinship care");

            Builder.Modify(form).With(f => f.ExistingChildren, ExistingChildrenBuilder.NewValid(3).LastNotKinshipCare());

            Navigation.RequiresApplicantBenefits(form).Should().BeTrue("should ask for applicant benefits if not all children in kinship care");

            Builder.Modify(form).With(f => f.ExistingChildren, ExistingChildrenBuilder.NewValid(3).AllKinshipCare());

            Navigation.RequiresApplicantBenefits(form).Should().BeFalse("should not ask for applicant benefits is all children are kinship care");

            Builder.Modify(form).With(f => f.ExpectedChildren, ExpectedChildrenBuilder.NewValid(m => { m.ExpectancyDate = null; m.ExpectedBabyCount = 1; }));

            Navigation.RequiresApplicantBenefits(form).Should().BeTrue("should not ask for applicant benefits, since an expected child is not expected to be in kinship care");

            Builder.Modify(form).With(f => f.ExpectedChildren, ExpectedChildrenBuilder.NewValid(m => { m.ExpectancyDate = TestNowUtc.Value; m.ExpectedBabyCount = null; }));

            Navigation.RequiresApplicantBenefits(form).Should().BeTrue("should not ask for applicant benefits, since an expected child is not expected to be in kinship care");
        }
 protected void ExistingChildrenShouldBeInvalid(BestStartGrant form, Action <ExistingChildren> mutator)
 {
     ShouldBeInvalid(() => form.AddExistingChildren(ExistingChildrenBuilder.NewValid(2, mutator)));
 }
        public void Ineligible_NoChildren()
        {
            Func <Action <BestStartGrant>, BestStartGrant> form = mutator => new BestStartGrantBuilder("form")
                                                                  .WithCompletedSections()
                                                                  .With(f => f.ExistingChildren, ExistingChildrenBuilder.NewValid(childCount: 0))
                                                                  .With(f => f.ExpectedChildren, ExpectedChildrenBuilder.NewValid(ec => ec.NoBabyExpected()))
                                                                  .Value(mutator);

            var lastChildSection = (Sections)Math.Max((int)Sections.ExistingChildren, (int)Sections.ExpectedChildren);

            Navigation.IsIneligible(form(f => { }), lastChildSection).Should().BeTrue("not eligible when there are no existing or expected children");

            Navigation.IsIneligible(form(f => { }), lastChildSection - 1).Should().BeFalse("ineligibility is not determined until both children sections are complete");
            Navigation.IsIneligible(form(f => { }), lastChildSection - 1).Should().BeFalse("ineligibility is not determined until both children sections are complete");
            Navigation.IsIneligible(form(f => f.ExpectedChildren.ExpectedBabyCount(1)), lastChildSection).Should().BeFalse("not ineligible if you are due a baby");
            Navigation.IsIneligible(form(f => f.ExpectedChildren.ExpectedBabyCount(2)), lastChildSection).Should().BeFalse("not ineligible if you are due a baby");
            Navigation.IsIneligible(form(f => f.ExistingChildren.AddChild()), lastChildSection).Should().BeFalse("potentially not ineligible if you have an existing child");
        }