public static ApplicantDetails NewValid(Action <ApplicantDetails> mutator = null) { var value = new ApplicantDetails { Title = "test title", FirstName = "test first name", OtherNames = "test other names", SurnameOrFamilyName = "test surname or family name", DateOfBirth = DomainRegistry.NowUtc().Date.AddYears(-19), PreviouslyLookedAfter = false, FullTimeEducation = false, NationalInsuranceNumber = "AB123456C", CurrentAddress = AddressBuilder.NewValid("applicant"), EmailAddress = "*****@*****.**", PhoneNumer = "01234 567 890", MobilePhoneNumber = "12345 678 901", }; if (mutator != null) { mutator(value); } return(value); }
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 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); }
public static ExpectedChildren ExpectedBabyCount(this ExpectedChildren expectedChildren, int?babyCount) { expectedChildren.IsBabyExpected = babyCount > 0; expectedChildren.ExpectancyDate = DomainRegistry.NowUtc().Date.AddDays(100); expectedChildren.IsMoreThan1BabyExpected = babyCount > 1; expectedChildren.ExpectedBabyCount = babyCount > 1 ? babyCount.Value : (int?)null; return(expectedChildren); }
public static ExpectedChildren Populate(ExpectedChildren expectedChildren, Action <ExpectedChildren> mutator = null) { expectedChildren.IsBabyExpected = true; expectedChildren.ExpectancyDate = DomainRegistry.NowUtc().Date + TimeSpan.FromDays(100); expectedChildren.IsMoreThan1BabyExpected = true; expectedChildren.ExpectedBabyCount = 2; mutator?.Invoke(expectedChildren); return(expectedChildren); }
private static ExistingChild NewChild(int index) { return(new ExistingChild { FirstName = $"child {index + 1} first name", Surname = $"child {index + 1} surname", DateOfBirth = DomainRegistry.NowUtc().Date.AddYears(-(10 + index * 2)), Relationship = Relationship.Parent, ChildBenefit = false, NoChildBenefitReason = $"unit test reason {index + 1}", }); }
protected void OnBeforeUpdate(bool isFinalUpdate) { if (Completed.HasValue) { throw new DomainException("This application has already been submitted and cannot be modified"); } if (isFinalUpdate) { Completed = DomainRegistry.NowUtc(); } }
internal int?Age() { if (!DateOfBirth.HasValue) { return(null); } var today = DomainRegistry.NowUtc().ToLocalTime().Date; var dob = DateOfBirth.Value; var age = today.Year - dob.Year; if (dob.AddYears(age) > today) { age--; // birthday has not happened this year } return(age); }
public static RelationDetails NewValid(string relation = "relation ", Action <RelationDetails> mutator = null) { var value = new RelationDetails { Title = "relation title", FullName = "relation name", DateOfBirth = DomainRegistry.NowUtc().Date.AddYears(-45), NationalInsuranceNumber = "BC123456D", RelationshipToApplicant = "Parent", InheritAddress = false, Address = AddressBuilder.NewValid(relation), }; if (mutator != null) { mutator(value); } return(value); }
protected Form(string id) { Id = id; Started = DomainRegistry.NowUtc(); }