private NextSection AddApplicantDetails(NextSection current, Action <ApplicantDetails> mutator = null)
 {
     current.Section.Should().Be(Sections.ApplicantDetails);
     return(NextSection(current.Section, () => new AddApplicantDetails {
         FormId = current.Id, ApplicantDetails = ApplicantDetailsBuilder.NewValid(mutator)
     }.Execute()));
 }
Exemplo n.º 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);
        }
        public void RequiresGuardianBenefits()
        {
            var form = new BestStartGrantBuilder("form")
                       .With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid())
                       .Value();

            form.ApplicantDetails.DateOfBirth = null;

            Navigation.RequiresGuardianBenefits(form).Should().BeFalse();

            form.ApplicantDetails.Over25(TestNowUtc.Value);
            form.ApplicantDetails.FullTimeEducation = true;
            BestStartGrant.ShouldAskEducationQuestion(form.ApplicantDetails).Should().BeFalse("question not relevant");

            Navigation.RequiresGuardianBenefits(form).Should().BeFalse("should not ask for guardian benefits if not 18 or 19");

            form.ApplicantDetails.Aged(TestNowUtc.Value, 18);
            form.ApplicantDetails.FullTimeEducation = false;
            BestStartGrant.ShouldAskEducationQuestion(form.ApplicantDetails).Should().BeTrue("ensure question is asked");

            Navigation.RequiresGuardianBenefits(form).Should().BeFalse("should not ask for guardian benefits if not in full time education");

            form.ApplicantDetails.Aged(TestNowUtc.Value, 19);
            form.ApplicantDetails.FullTimeEducation = true;
            BestStartGrant.ShouldAskEducationQuestion(form.ApplicantDetails).Should().BeTrue("ensure question is asked");

            Navigation.RequiresGuardianBenefits(form).Should().BeTrue("should ask for guardian benefits if responded in full time education");
        }
        public void RequiresApplicantBenefits_NotRequiredWhenCareLeaver()
        {
            var form = new BestStartGrantBuilder("form")
                       .With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid())
                       .Value();

            form.ApplicantDetails.DateOfBirth = null;

            Navigation.RequiresGuardianBenefits(form).Should().BeFalse();

            form.ApplicantDetails.Over25(TestNowUtc.Value);
            form.ApplicantDetails.PreviouslyLookedAfter = true;
            BestStartGrant.ShouldAskCareQuestion(form.ApplicantDetails).Should().BeFalse("question not relevant");

            Navigation.RequiresApplicantBenefits(form).Should().BeTrue("should still ask for benefits if not under 25 (despite previous care)");

            form.ApplicantDetails.Aged(TestNowUtc.Value, 23);
            form.ApplicantDetails.PreviouslyLookedAfter = false;
            BestStartGrant.ShouldAskCareQuestion(form.ApplicantDetails).Should().BeTrue("ensure question is asked");

            Navigation.RequiresApplicantBenefits(form).Should().BeTrue("should still ask for benefits if not previously in care");

            form.ApplicantDetails.Aged(TestNowUtc.Value, 23);
            form.ApplicantDetails.PreviouslyLookedAfter = true;
            BestStartGrant.ShouldAskCareQuestion(form.ApplicantDetails).Should().BeTrue("ensure question is asked");

            Navigation.RequiresApplicantBenefits(form).Should().BeFalse("should ask for guardian benefits if responded in full time education");
        }
Exemplo n.º 5
0
        public ChangeOfCircsBuilder WithCompletedSections(bool markAsCompleted = true, bool excludeOptionalSections = false)
        {
            With(f => f.Consent, ConsentBuilder.NewValid());
            With(f => f.UserId, "*****@*****.**");
            With(f => f.ExistingApplicantDetails, ApplicantDetailsBuilder.NewValid(ad => ad.Address = AddressBuilder.NewValid("existing")));
            With(f => f.ExistingPaymentDetails, PaymentDetailsBuilder.NewValid());
            With(f => f.Options, OptionsBuilder.NewValid());

            if (!excludeOptionalSections)
            {
                With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid());
                With(f => f.ExpectedChildren, ExpectedChildrenBuilder.NewValid());
                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());
            VerifyConsistent(_instance);

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

            return(this);
        }
        protected void ApplicantDetailsShouldBeValid(BestStartGrant form, Action <ApplicantDetails> mutator, Action <ApplicantDetails> postVerify = null)
        {
            var applicantDetails = ApplicantDetailsBuilder.NewValid(mutator);

            ShouldBeValid(() => form.AddApplicantDetails(applicantDetails));
            postVerify?.Invoke(applicantDetails);
        }
        public void ApplicantDetails_RequiresEducationQuestion()
        {
            TestNowUtc = new DateTime(2009, 08, 07, 06, 05, 04);
            var applicantDetails = ApplicantDetailsBuilder.NewValid();

            BestStartGrant.ShouldAskEducationQuestion(applicantDetails).Should().BeTrue("default builder should ask question");

            applicantDetails.DateOfBirth = null;
            BestStartGrant.ShouldAskEducationQuestion(applicantDetails).Should().BeFalse("no need to ask question if DoB not supplied");

            // applicant is 20 today
            applicantDetails.DateOfBirth = new DateTime(1989, 08, 07);
            BestStartGrant.ShouldAskEducationQuestion(applicantDetails).Should().BeFalse("no need to ask question if applicant >= 20");

            // applicant is 20 tomorrow (still 19)
            applicantDetails.DateOfBirth = new DateTime(1989, 08, 08);
            BestStartGrant.ShouldAskEducationQuestion(applicantDetails).Should().BeTrue("ask question if applicant is still 19");

            // applicant is 18 today
            applicantDetails.DateOfBirth = new DateTime(1991, 08, 07);
            BestStartGrant.ShouldAskEducationQuestion(applicantDetails).Should().BeTrue("ask question if applicant has turned 18");

            // applicant is 18 tomorrow
            applicantDetails.DateOfBirth = new DateTime(1991, 08, 08);
            BestStartGrant.ShouldAskEducationQuestion(applicantDetails).Should().BeFalse("no need to ask question if applicant is under 18");
        }
        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);
        }
        public void RequiresGuardianPartnerBenefits_NotRequiredWhenAnyBenefitsNotRequired()
        {
            var form = new BestStartGrantBuilder("form")
                       .With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid().Under25CareLeaver(TestNowUtc.Value))
                       .With(f => f.GuardianBenefits, BenefitsBuilder.NewNone())
                       .Value();

            Navigation.RequiresGuardianPartnerBenefits(form).Should().BeFalse("should not prompt for benefits when already entitled");
        }
        public void ApplicantDetails_UsesEmailToIdentifyUser()
        {
            var form    = new BestStartGrantBuilder("form").Insert();
            var details = ApplicantDetailsBuilder.NewValid(d => d.EmailAddress = "test.email");

            form.AddApplicantDetails(details);

            form.UserId.Should().Be("test.email");
        }
Exemplo n.º 11
0
        public void Find_NoNationalInsuranceNumber()
        {
            var query = new FindApplicantDetailsConfig
            {
                ApplicantDetails = ApplicantDetailsBuilder.NewValid(ad => ad.Under16(TestNowUtc.Value)),
            };

            var detail = query.Find();

            detail.ShouldAskForNationalInsuranceNumber.Should().BeFalse();
        }
Exemplo n.º 12
0
        public void Find_OneQuestionAsked()
        {
            var query = new FindApplicantDetailsConfig
            {
                ApplicantDetails = ApplicantDetailsBuilder.NewValid(ad => ad.DateOfBirth = TestNowUtc.Value.Date.AddYears(-21)),
            };

            var detail = query.Find();

            detail.ShouldAskCareQuestion.Should().BeTrue();
            detail.ShouldAskEducationQuestion.Should().BeFalse();
        }
        public void Populate_SetsPreviousSection()
        {
            var form = new BestStartGrantBuilder("form")
                       .With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid().Under16(TestNowUtc.Value))
                       .Value();

            var detail = new BsgDetail();

            Navigation.Populate(detail, Sections.GuardianDetails, form);

            detail.PreviousSection.Should().Be(Sections.ExistingChildren,
                                               "Navigating backwards from guardian details for a 16 year old should go back to existing children (and skip applicant benefits)");
        }
Exemplo n.º 14
0
        public void Find_AllCareQuestionsAsked()
        {
            var query = new FindApplicantDetailsConfig
            {
                ApplicantDetails = ApplicantDetailsBuilder.NewValid(),
            };

            var detail = query.Find();

            detail.ShouldAskCareQuestion.Should().BeTrue();
            detail.ShouldAskEducationQuestion.Should().BeTrue();
            detail.ShouldAskForNationalInsuranceNumber.Should().BeTrue();
        }
        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");
        }
        public void ApplicantDetails_RequiresNationalInsuranceNumber()
        {
            TestNowUtc = new DateTime(2009, 08, 07, 06, 05, 04);
            var applicantDetails = ApplicantDetailsBuilder.NewValid();

            BestStartGrant.ShouldAskForNationalInsuranceNumber(applicantDetails).Should().BeTrue("default builder should ask question");

            applicantDetails.DateOfBirth = null;
            BestStartGrant.ShouldAskForNationalInsuranceNumber(applicantDetails).Should().BeTrue("should ask by default");

            // applicant is 16 today
            applicantDetails.DateOfBirth = new DateTime(1993, 08, 07);
            BestStartGrant.ShouldAskForNationalInsuranceNumber(applicantDetails).Should().BeTrue("ask for NINO if >= 16");

            // applicant is 16 tomorrow (still 15)
            applicantDetails.DateOfBirth = new DateTime(1993, 08, 08);
            BestStartGrant.ShouldAskForNationalInsuranceNumber(applicantDetails).Should().BeFalse("under 16 does not have NINO");
        }
        public void RequiresApplicantBenefits_NotRequiredWhenAskingGuardianBenefits()
        {
            var form = new BestStartGrantBuilder("form")
                       .With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid())
                       .Value();

            form.ApplicantDetails.Aged(TestNowUtc.Value, 18);
            form.ApplicantDetails.FullTimeEducation = false;
            BestStartGrant.ShouldAskEducationQuestion(form.ApplicantDetails).Should().BeTrue("ensure question is asked");

            Navigation.RequiresApplicantBenefits(form).Should().BeTrue("should ask for applicant benefits if not asking for guardian benefits");

            form.ApplicantDetails.Aged(TestNowUtc.Value, 19);
            form.ApplicantDetails.FullTimeEducation = true;
            BestStartGrant.ShouldAskEducationQuestion(form.ApplicantDetails).Should().BeTrue("ensure question is asked");

            Navigation.RequiresApplicantBenefits(form).Should().BeFalse("should not ask for applicant benefits if asking for guardian benefits");
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
0
        public void Execute_StoresApplicantDetails()
        {
            var existingForm = new ChangeOfCircsBuilder("form123")
                               .Insert();

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

            var cmd = new AddApplicantDetails
            {
                FormId           = "form123",
                ApplicantDetails = ApplicantDetailsBuilder.NewValid(),
            };

            cmd.Execute();

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

            updatedForm.ApplicantDetails.Should().NotBeNull();
            updatedForm.ApplicantDetails.FullName.Should().Be(cmd.ApplicantDetails.FullName);
        }
        public void RequiresGuardianDetails_FullTimeEducation()
        {
            var form = new BestStartGrantBuilder("form")
                       .With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid().PartOfGuardianBenefits(TestNowUtc.Value))
                       .With(f => f.GuardianBenefits, null)
                       .Value();

            Navigation.RequiresGuardianDetails(form).Should().BeFalse("until guardian benefits are collected, we don't need their details");

            Builder.Modify(form).With(f => f.GuardianBenefits, BenefitsBuilder.NewNone());

            Navigation.RequiresGuardianDetails(form).Should().BeFalse("guardian details not required if we know they don't have a qualifying benefit");

            form.GuardianBenefits.WithBenefit();

            Navigation.RequiresGuardianDetails(form).Should().BeTrue("guardian details required if relying on their qualifying benefits");

            form.GuardianBenefits.Unknown();

            Navigation.RequiresGuardianDetails(form).Should().BeTrue("guardian details required if not sure if relying on their benefits");
        }
Exemplo n.º 21
0
        public void Execute_StoresExpectedDetails()
        {
            var existingForm = new BestStartGrantBuilder("form123")
                               .With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid())
                               .Insert();

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

            var cmd = new AddExpectedChildren
            {
                FormId           = "form123",
                ExpectedChildren = ExpectedChildrenBuilder.NewValid(),
            };

            cmd.Execute();

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

            updatedForm.ExpectedChildren.Should().NotBeNull();
            updatedForm.ExpectedChildren.ExpectancyDate.Should().Be(cmd.ExpectedChildren.ExpectancyDate);
        }
        public void RequiresApplicantBenefits()
        {
            var form = new BestStartGrantBuilder("form")
                       .With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid())
                       .Value();

            TestNowUtc = new DateTime(2009, 08, 07, 06, 05, 04);

            form.ApplicantDetails.DateOfBirth = null;

            Navigation.RequiresApplicantBenefits(form).Should().BeTrue();

            // 18 tomorrow
            form.ApplicantDetails.DateOfBirth = new DateTime(1991, 08, 08);

            Navigation.RequiresApplicantBenefits(form).Should().BeFalse("under 18 does not require applicant benefits");

            // 18 today
            form.ApplicantDetails.DateOfBirth = new DateTime(1991, 08, 07);

            Navigation.RequiresApplicantBenefits(form).Should().BeTrue();
        }
        public void RequiresGuardianDetails_Under16()
        {
            var form = new BestStartGrantBuilder("form")
                       .With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid())
                       .Value();

            TestNowUtc = new DateTime(2009, 08, 07, 06, 05, 04);

            form.ApplicantDetails.DateOfBirth = null;

            Navigation.RequiresGuardianDetails(form).Should().BeTrue();

            // 16 tomorrow
            form.ApplicantDetails.DateOfBirth = new DateTime(1993, 08, 08);

            Navigation.RequiresGuardianDetails(form).Should().BeTrue();

            // 16 today
            form.ApplicantDetails.DateOfBirth = new DateTime(1993, 08, 07);

            Navigation.RequiresGuardianDetails(form).Should().BeFalse("over 16 does not require a legal guradian/parent");
        }
        public void Execute_StoresHealthProfessionalDetails()
        {
            var existingForm = new BestStartGrantBuilder("form123")
                               .With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid())
                               .With(f => f.ExpectedChildren, ExpectedChildrenBuilder.NewValid())
                               .With(f => f.ExistingChildren, ExistingChildrenBuilder.NewValid())
                               .Insert();

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

            var cmd = new AddHealthProfessional
            {
                FormId             = "form123",
                HealthProfessional = HealthProfessionalBuilder.NewValid(),
            };

            cmd.Execute();

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

            updatedForm.HealthProfessional.Should().NotBeNull();
            updatedForm.HealthProfessional.Pin.Should().Be(cmd.HealthProfessional.Pin);
        }
        public void RequiresPartnerDetails()
        {
            var form = new BestStartGrantBuilder("form")
                       .With(f => f.ApplicantDetails, ApplicantDetailsBuilder.NewValid().Over25(TestNowUtc.Value))
                       .With(f => f.ApplicantBenefits, BenefitsBuilder.NewNone())
                       .With(f => f.PartnerBenefits, null)
                       .Value();

            Navigation.RequiresPartnerBenefits(form).Should().BeTrue("test logic requires that the partner benefits are requested");

            Navigation.RequiresPartnerDetails(form).Should().BeFalse("until partner benefits are collected, we don't need their details");

            Builder.Modify(form).With(f => f.PartnerBenefits, BenefitsBuilder.NewNone());

            Navigation.RequiresPartnerDetails(form).Should().BeFalse("partner details not required if we know they don't have a qualifying benefit");

            form.PartnerBenefits.WithBenefit();

            Navigation.RequiresPartnerDetails(form).Should().BeTrue("partner details required if relying in their qualifying benefits");

            form.PartnerBenefits.Unknown();

            Navigation.RequiresPartnerDetails(form).Should().BeTrue("partner details required if not sure if relying on their benefits");
        }
Exemplo n.º 26
0
 protected void ApplicantDetailsShouldBeInvalid(ChangeOfCircs form, Action <ApplicantDetails> mutator)
 {
     ShouldBeInvalid(() => form.AddApplicantDetails(ApplicantDetailsBuilder.NewValid(mutator)));
 }
 protected void ApplicantDetailsShouldBeInvalid(BestStartGrant form, Action <ApplicantDetails> mutator)
 {
     ShouldBeInvalid(() => form.AddApplicantDetails(ApplicantDetailsBuilder.NewValid(mutator)));
 }