public void Evidence_POST_RemoveFile() { WebAppTest(client => { // prep this test by adding a file to remove var cloudName = System.Guid.NewGuid().ToString(); var detail = NewBsgDetail("form123"); detail.Evidence.Files.Add(new EvidenceFile { Name = "UploadedFile.pdf", CloudName = cloudName }); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); // now remove it var response = client.Get(BsgActions.Evidence(detail.Id)) .Form <EvidenceFile>(1) .SubmitName(BsgButtons.RemoveFile, client); ExecutorStub.Executed <RemoveEvidenceFile>(0).ShouldBeEquivalentTo(new RemoveEvidenceFile { FormId = detail.Id, CloudName = cloudName, }); response.ActionResultOf <RedirectResult>().Url.Should().Be(BsgActions.Evidence(detail.Id)); }); }
public void PaymentDetails_POST_StoresData() { WebAppTest(client => { var response = client.Get(BsgActions.PaymentDetails("form123")).Form <PaymentDetails>(1) .SelectYes(m => m.HasBankAccount) .SetText(m => m.NameOfAccountHolder, "test name") .SetText(m => m.NameOfBank, "test bank") .SetText(m => m.SortCode, "01-02-03") .SetText(m => m.AccountNumber, "01234567") .SetText(m => m.RollNumber, "roll/number") .Submit(client); ExecutorStub.Executed <AddPaymentDetails>(0).ShouldBeEquivalentTo(new AddPaymentDetails { FormId = "form123", PaymentDetails = new PaymentDetails { HasBankAccount = true, NameOfAccountHolder = "test name", NameOfBank = "test bank", SortCode = "01-02-03", AccountNumber = "01234567", RollNumber = "roll/number", }, }); response.ActionResultOf <RedirectResult>().Url.Should().NotBeNullOrWhiteSpace(); }); }
public void Declaration_POST_CompletesForm() { WebAppTest(client => { // the declaration form is now dependent on a completed ApplicantDetails, so... var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny<FindBsgSection>(), detail); ExecutorStub.SetupCommand(It.IsAny<AddDeclaration>(), new NextSection { Type = NextType.Complete }); var response = client.Get(BsgActions.Declaration(detail.Id)).Form<Declaration>(1) .SelectConfirm(m => m.AgreedToLegalStatement, true) .Submit(client); ExecutorStub.Executed<AddDeclaration>(0).ShouldBeEquivalentTo(new AddDeclaration { FormId = "form123", Declaration = new Declaration { AgreedToLegalStatement = true, }, }); response.ActionResultOf<RedirectResult>().Url.Should().Be(BsgActions.Complete()); }); }
public async Task Can_EditBlueprint() { ExecutorStub.StubResult(Agreements.FindBlueprint); ExecutorStub.StubResult(Agreements.Edit); var client = MvcTestingClient(); var getResponse = await client .GetAsync(Actions.Edit(123)); var model = getResponse.ViewResultModel <StartEditModel>(); model.Title.Should().Be("Edit Blueprint"); model.ButtonText.Should().Be("Update"); var form = getResponse.Form <StartEditCommand>(); form.GetText(m => m.Name).Should().Be("TestBlueprint"); var response = await form .SetText(m => m.Name, "UpdatedBlueprint") .Submit(); ExecutorStub.VerifySingleExecuted(Agreements.Edit); }
public void PartnerDetails_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.PartnerDetails(detail.Id)); ExecutorStub.Executed <FindBsgSection>(0).ShouldBeEquivalentTo(new FindBsgSection { FormId = detail.Id, Section = Sections.PartnerDetails }); var form = response.Doc.Form <RelationDetails>(1); form.GetText(m => m.Title).Should().Be(detail.PartnerDetails.Title); form.Get(m => m.RelationshipToApplicant).Length.Should().Be(0, "Should not ask partner's relationship"); form.GetText(m => m.Address.Line1).Should().Be(detail.PartnerDetails.Address.Line1); form.Get(m => m.InheritAddress).Length.Should().Be(1, "option to inherit address should be visible"); form.WhenCheckedShows(m => m.InheritAddress, "inherited-address"); form.WhenUncheckedShows(m => m.InheritAddress, "new-address"); }); }
public void HealthProfessional_POST_ErrorsAreDisplayed() { WebAppTest(client => { ExecutorStub.SetupCommand <AddHealthProfessional, NextSection>((cmd, def) => { throw new DomainException("simulated logic error"); }); var response = client.Get(CocActions.HealthProfessional("form123")).Form <HealthProfessional>(1) .Submit(client, r => r.SetExpectedResponse(HttpStatusCode.OK)); response.Doc.Find(".validation-summary-errors").Should().NotBeNull(); }); }
public void FirstSectionDoesNotNeedId() { WebAppTest(client => { ExecutorStub.SetupQuery <FindBsgSection, BsgDetail>((cmd, r) => { throw new DomainException("cannot call FindBsgSection with a null id"); }); var firstSection = Navigation.Order.First(); var firstAction = SectionActionStrategy.For(firstSection).Action(null); client.Get(firstAction); }); }
public void ApplicantBenefits_POST_ErrorsAreDisplayed() { WebAppTest(client => { ExecutorStub.SetupCommand <AddApplicantBenefits, NextSection>((cmd, def) => { throw new DomainException("simulated logic error"); }); var response = client.Get(BsgActions.ApplicantBenefits("form123")).Form <Benefits>(1) .SubmitName("", client, r => r.SetExpectedResponse(HttpStatusCode.OK)); response.Doc.Find(".validation-summary-errors").Should().NotBeNull(); }); }
public void Declaration_GET_HandlesMissingSections() { WebAppTest(client => { var detail = new BsgDetail { Id = "form123" }; ExecutorStub.SetupQuery(It.IsAny<FindBsgSection>(), detail); var response = client.Get(BsgActions.Declaration(detail.Id)); response.HttpStatusCode.Should().Be(HttpStatusCode.OK); }); }
public void Declaration_GET() { WebAppTest(client => { // the declaration form is now dependent on a completed ApplicantDetails, so... var detail = NewBsgDetail("form123"); // with default age ... ExecutorStub.SetupQuery(It.IsAny<FindBsgSection>(), detail); var response = client.Get(BsgActions.Declaration(detail.Id)); response.Text.ToLower().Should().Contain("the information you've given"); }); }
public void DeclarationU16_GET() { WebAppTest(client => { // the declaration form is now dependent on a completed ApplicantDetails, so... var detail = NewBsgDetail("form123"); // then ensure under 16... detail.ApplicantDetails.DateOfBirth = System.DateTime.Now.AddYears(-15); ExecutorStub.SetupQuery(It.IsAny<FindBsgSection>(), detail); var response = client.Get(BsgActions.Declaration(detail.Id)); response.Text.ToLower().Should().Contain("you are under the age of 16"); }); }
public void NextSection_RedirectToNextSection() { WebAppTest(client => { ExecutorStub.SetupCommand(It.IsAny <AddApplicantDetails>(), new NextSection { Type = NextType.Section, Id = "form123", Section = Sections.ExistingChildren }); var response = client.Get(BsgActions.ApplicantDetails("form123")).Form <ApplicantDetails>(1).Submit(client); response.ActionResultOf <RedirectResult>().Url.Should().Be(BsgActions.ExistingChildren("form123")); }); }
public void Declaration_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny<FindBsgSection>(), detail); var response = client.Get(BsgActions.Declaration(detail.Id)); ExecutorStub.Executed<FindBsgSection>(0).ShouldBeEquivalentTo(new FindBsgSection { FormId = detail.Id, Section = Sections.Declaration }); response.Doc.Form<Declaration>(1).GetConfirm(m => m.AgreedToLegalStatement).Should().Be(detail.Declaration.AgreedToLegalStatement); }); }
public async Task CanSeeListOfBlueprints() { ExecutorStub.StubResult(Agreements.FindBlueprints); var response = await MvcTestingClient() .GetAsync(Actions.List()); ExecutorStub.VerifySingleExecuted(Agreements.FindBlueprints); response.Doc.Find(".blueprintList").Should().NotBeNull(); response.Doc.FindAll(".blueprintItem").Count.Should().Be(2); response.Doc.Find(".blueprintItem:nth-child(1) a").Attribute("href").Should().StartWith(Actions.Edit(101)); }
public void ExistingChildren_GET_WhenNoExistingChildren_PrePopulatesOneChild() { WebAppTest(client => { var detail = NewBsgDetail("form123"); detail.ExistingChildren.Children = new List <ExistingChild>(); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.ExistingChildren(detail.Id)); response.Doc.FindAll(".existing-child").Count.Should().Be(1, "should have at least one child pre-populated (albeit hidden)"); }); }
public void ExistingChildren_AsksChildDetails_OnlyWhenSelectedYesToChildren() { WebAppTest(client => { var detail = NewBsgDetail("form123", 2); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.ExistingChildren(detail.Id)); var form = response.Form <ExistingChildren>(1); form.RadioShows(m => m.AnyExistingChildren, true, "children-details"); response.Doc.FindAll("button[name=RemoveChild]").Count.Should().Be(2, "should have 2 remove buttons"); }); }
public void ExistingChildren_AsksForReason_OnlyWhenNoChildBenefit() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.ExistingChildren(detail.Id)); var form = response.Form <ExistingChildren>(1); form.RadioShows(m => m.Children[0].ChildBenefit, false, "child0-reason"); form.RadioShows(m => m.Children[1].ChildBenefit, false, "child1-reason"); }); }
public void ExistingChildren_POST_StoresData() { WebAppTest(client => { var response = client.Get(BsgActions.ExistingChildren("form123")).Form <ExistingChildren>(1) .SelectYes(m => m.AnyExistingChildren) .SetText(m => m.Children[0].FirstName, "child 0 first name") .SetText(m => m.Children[0].Surname, "child 0 surname") .SetDate(m => m.Children[0].DateOfBirth, "03", "04", "2005") .SetText(m => m.Children[0].Relationship, Relationship.KinshipCarer.ToString()) .SelectYes(m => m.Children[0].ChildBenefit) .SubmitName(BsgButtons.AddChild, client, r => r.SetExpectedResponse(HttpStatusCode.OK)).Form <ExistingChildren>(1) // add a second child .SetText(m => m.Children[1].FirstName, "child 1 first name") .SetText(m => m.Children[1].Surname, "child 1 surname") .SetDate(m => m.Children[1].DateOfBirth, "02", "03", "2004") .SetText(m => m.Children[1].Relationship, Relationship.Parent.ToString()) // leave child benefit as null/empty .SubmitName("", client); ExecutorStub.Executed <AddExistingChildren>(0).ShouldBeEquivalentTo(new AddExistingChildren { FormId = "form123", ExistingChildren = new ExistingChildren { AnyExistingChildren = true, Children = new List <ExistingChild>() { new ExistingChild { FirstName = "child 0 first name", Surname = "child 0 surname", DateOfBirth = new DateTime(2005, 04, 03), Relationship = Relationship.KinshipCarer, ChildBenefit = true, }, new ExistingChild { FirstName = "child 1 first name", Surname = "child 1 surname", DateOfBirth = new DateTime(2004, 03, 02), Relationship = Relationship.Parent, ChildBenefit = null, }, }, }, }); response.ActionResultOf <RedirectResult>().Url.Should().NotBeNullOrWhiteSpace(); }); }
public void ExistingChildren_GET_WhenExactlyOneChild_NoRemoveButtonIsShown() { WebAppTest(client => { var detail = NewBsgDetail("form123", 1); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.ExistingChildren(detail.Id)); var form = response.Form <ExistingChildren>(1); form.RadioShows(m => m.AnyExistingChildren, true, "children-details"); response.Doc.FindAll("button[name=RemoveChild]").Count.Should().Be(0, "no remove child button when there's only 1 child (select 'no' instead)"); }); }
public void ExpectedChildren_GET_DefaultsToExpectedBaby_AndHidesQuestion() { WebAppTest(client => { var detail = NewCocDetail("form123"); detail.ExpectedChildren = null; ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.ExpectedChildren(detail.Id)); response.Doc.Form <ExpectedChildren>(1).GetText(m => m.IsBabyExpected).Should().Be(true.ToString()); response.Doc.Find("#IsBabyExpected_FormGroup").ShouldBeHidden(); }); }
public void HealthProfessional_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewCocDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.HealthProfessional(detail.Id)); ExecutorStub.Executed <FindCocSection>(0).ShouldBeEquivalentTo(new FindCocSection { FormId = detail.Id, Section = Sections.HealthProfessional }); response.Doc.Form <HealthProfessional>(1).GetText(m => m.Pin).Should().Be(detail.HealthProfessional.Pin); }); }
public void Identity_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewCocDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.Identity(detail.Id)); ExecutorStub.Executed <FindCocSection>(0).ShouldBeEquivalentTo(new FindCocSection { FormId = detail.Id, Section = Sections.Identity }); response.Doc.Form <IdentityModel>(1).GetText(m => m.Email).Should().Be(detail.Identity); }); }
public void ApplicantBenefits_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.ApplicantBenefits(detail.Id)); ExecutorStub.Executed <FindBsgSection>(0).ShouldBeEquivalentTo(new FindBsgSection { FormId = detail.Id, Section = Sections.ApplicantBenefits }); response.Doc.Form <Benefits>(1).GetConfirm(m => m.HasIncomeSupport).Should().Be(detail.ApplicantBenefits.HasIncomeSupport); }); }
public void ApplicantDetails_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewCocDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.ApplicantDetails(detail.Id)); ExecutorStub.Executed <FindCocSection>(0).ShouldBeEquivalentTo(new FindCocSection { FormId = detail.Id, Section = Sections.ApplicantDetails }); response.Doc.Form <ApplicantDetails>(1).GetText(m => m.FullName).Should().Be(detail.ApplicantDetails.FullName); }); }
public void PaymentDetails_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.PaymentDetails(detail.Id)); ExecutorStub.Executed <FindBsgSection>(0).ShouldBeEquivalentTo(new FindBsgSection { FormId = detail.Id, Section = Sections.PaymentDetails }); response.Doc.Form <PaymentDetails>(1).GetText(m => m.NameOfAccountHolder).Should().Be(detail.PaymentDetails.NameOfAccountHolder); }); }
public void GuardianDetails_GET_PopulatesExistingAddressDetails() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.GuardianDetails(detail.Id)); ExecutorStub.Executed <FindBsgSection>(0).ShouldBeEquivalentTo(new FindBsgSection { FormId = detail.Id, Section = Sections.GuardianDetails }); response.Doc.Form <RelationDetails>(1).GetText(m => m.Address.Line1).Should().Be(detail.GuardianDetails.Address.Line1); }); }
public void ExpectedChildren_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.ExpectedChildren(detail.Id)); ExecutorStub.Executed <FindBsgSection>(0).ShouldBeEquivalentTo(new FindBsgSection { FormId = detail.Id, Section = Sections.ExpectedChildren }); response.Doc.Form <ExpectedChildren>(1).GetText(m => m.ExpectedBabyCount).Should().Be(detail.ExpectedChildren.ExpectedBabyCount.ToString()); }); }
public void Options_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewCocDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.Options(detail.Id)); ExecutorStub.Executed <FindCocSection>(0).ShouldBeEquivalentTo(new FindCocSection { FormId = detail.Id, Section = Sections.Options }); response.Doc.Form <Options>(1).GetConfirm(m => m.ChangePersonalDetails).Should().Be(detail.Options.ChangePersonalDetails); }); }
public void Evidence_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.Evidence(detail.Id)); ExecutorStub.Executed <FindBsgSection>(0).ShouldBeEquivalentTo(new FindBsgSection { FormId = detail.Id, Section = Sections.Evidence }); response.Doc.Form <Evidence>(1).GetConfirm(m => m.SendingByPost).Should().Be(detail.Evidence.SendingByPost); response.Doc.Document.Body.TextContent.Should().Contain("No files uploaded"); }); }
public async Task Login_RedirectsToOriginalPage() { ExecutorStub.StubResult(Agreements.Login); var action = Actions.Login() + $"/?returnUrl={HttpUtility.UrlEncode("http://someUrl")}"; var form = await MvcTestingClient() .GetAsync(action) .Form <LoginCommand>(); var response = await form .SetText(m => m.UserName, "User1") .Submit(); response.ActionResultOf <RedirectResult>().Url.Should().Be("http://someUrl"); }
public static void SetupExecutorStub() { ExecutorStub = new ExecutorStub(); PresentationRegistry.Executor = new CqExecutor(ExecutorStub); }