public void Evidence_POST_RemoveFile() { WebAppTest(client => { // prep this test by adding a file to remove var cloudName = System.Guid.NewGuid().ToString(); var detail = NewCocDetail("form123"); detail.Evidence.Files.Add(new EvidenceFile { Name = "UploadedFile.pdf", CloudName = cloudName }); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); // now remove it var response = client.Get(CocActions.Evidence(detail.Id)) .Form <EvidenceFile>(1) .SubmitName(CocButtons.RemoveFile, client); ExecutorStub.Executed <RemoveEvidenceFile>(0).ShouldBeEquivalentTo(new RemoveEvidenceFile { FormId = "form123", CloudName = cloudName, }); response.ActionResultOf <RedirectResult>().Url.Should().Be(CocActions.Evidence("form123")); }); }
public void Complete_GET() { WebAppTest(client => { var response = client.Get(CocActions.Complete()); response.Text.ToLower().Should().Contain("received"); }); }
public void Options_AsksForOtherDetail_OnlyWhenOtherSelected() { WebAppTest(client => { var response = client.Get(CocActions.Options("form")); var form = response.Form <Options>(1); form.WhenCheckedShows(m => m.Other, "other-detail"); }); }
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 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 Declaration_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewCocDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.Declaration(detail.Id)); ExecutorStub.Executed <FindCocSection>(0).ShouldBeEquivalentTo(new FindCocSection { FormId = detail.Id, Section = Sections.Declaration }); response.Doc.Form <Declaration>(1).GetConfirm(m => m.AgreedToLegalStatement).Should().Be(detail.Declaration.AgreedToLegalStatement); }); }
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 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 ExpectedChildren_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewCocDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.ExpectedChildren(detail.Id)); ExecutorStub.Executed <FindCocSection>(0).ShouldBeEquivalentTo(new FindCocSection { FormId = detail.Id, Section = Sections.ExpectedChildren }); response.Doc.Form <ExpectedChildren>(1).GetText(m => m.ExpectedBabyCount).Should().Be(detail.ExpectedChildren.ExpectedBabyCount.ToString()); }); }
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 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 Declaration_POST_ErrorsAreDisplayed() { WebAppTest(client => { // the declaration form is now dependent on a completed ApplicantDetails, so... // even if the form is not queried such as this test, the browser cannot render the page without ApplicantDetails var detail = NewCocDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); ExecutorStub.SetupCommand <AddDeclaration, NextSection>((cmd, def) => { throw new DomainException("simulated logic error"); }); var response = client.Get(CocActions.Declaration("form123")).Form <Declaration>(1) .Submit(client, r => r.SetExpectedResponse(HttpStatusCode.OK)); response.Doc.Find(".validation-summary-errors").Should().NotBeNull(); }); }
public void Evidence_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewCocDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.Evidence(detail.Id)); ExecutorStub.Executed <FindCocSection>(0).ShouldBeEquivalentTo(new FindCocSection { 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 void Identity_POST_PopulatesIdentity() { WebAppTest(client => { var response = client.Get(CocActions.Identity("form123")).Form <IdentityModel>(1) .SetText(m => m.Email, "*****@*****.**") .Submit(client); ExecutorStub.Executed <AddIdentity>(0).ShouldBeEquivalentTo(new AddIdentity { FormId = "form123", Identity = "*****@*****.**", }); response.ActionResultOf <RedirectResult>().Url.Should().NotBeNullOrWhiteSpace(); }); }
public void Options_POST_PopulatesOptions() { WebAppTest(client => { var response = client.Get(CocActions.Options("form123")).Form <Options>(1) .SelectConfirm(m => m.ChangePersonalDetails, true) .Submit(client); ExecutorStub.Executed <AddOptions>(0).ShouldBeEquivalentTo(new AddOptions { FormId = "form123", Options = new Options { ChangePersonalDetails = true }, }); response.ActionResultOf <RedirectResult>().Url.Should().NotBeNullOrWhiteSpace(); }); }
public void Evidence_POST_PopulatesEvidence() { WebAppTest(client => { var response = client.Get(CocActions.Evidence("form123")).Form <Evidence>(1) .SelectConfirm(m => m.SendingByPost, true) .SubmitName("", client); ExecutorStub.Executed <AddEvidence>(0).ShouldBeEquivalentTo(new AddEvidence { FormId = "form123", Evidence = new Evidence { SendingByPost = true }, }); response.ActionResultOf <RedirectResult>().Url.Should().NotBeNullOrWhiteSpace(); }); }
public void PaymentDetails_POST_PopulatesPaymentDetails() { WebAppTest(client => { var response = client.Get(CocActions.PaymentDetails("form123")).Form <PaymentDetails>(1) .SetText(m => m.NameOfAccountHolder, "test full name") .Submit(client); ExecutorStub.Executed <AddPaymentDetails>(0).ShouldBeEquivalentTo(new AddPaymentDetails { FormId = "form123", PaymentDetails = new PaymentDetails { NameOfAccountHolder = "test full name" }, }); response.ActionResultOf <RedirectResult>().Url.Should().NotBeNullOrWhiteSpace(); }); }
public void ExpectedChildren_POST_PopulatesExpectedChildren() { WebAppTest(client => { var response = client.Get(CocActions.ExpectedChildren("form123")).Form <ExpectedChildren>(1) .SetText(m => m.ExpectedBabyCount, "2") .Submit(client); ExecutorStub.Executed <AddExpectedChildren>(0).ShouldBeEquivalentTo(new AddExpectedChildren { FormId = "form123", ExpectedChildren = new ExpectedChildren { IsBabyExpected = true, ExpectedBabyCount = 2 }, }); response.ActionResultOf <RedirectResult>().Url.Should().NotBeNullOrWhiteSpace(); }); }
public void ApplicantDetails_POST_PopulatesApplicantDetails() { WebAppTest(client => { var response = client.Get(CocActions.ApplicantDetails("form123")).Form <ApplicantDetails>(1) .SetText(m => m.FullName, "test full name") .Submit(client); ExecutorStub.Executed <AddApplicantDetails>(0).ShouldBeEquivalentTo(new AddApplicantDetails { FormId = "form123", ApplicantDetails = new ApplicantDetails { FullName = "test full name" }, }); response.ActionResultOf <RedirectResult>().Url.Should().NotBeNullOrWhiteSpace(); }); }
public void Consent_POST_PopulatesConsent() { WebAppTest(client => { var response = client.Get(CocActions.Consent("form123")).Form <Consent>(1) .SelectConfirm(m => m.AgreedToConsent, true) .Submit(client); ExecutorStub.Executed <AddConsent>(0).ShouldBeEquivalentTo(new AddConsent { FormId = "form123", Consent = new Consent { AgreedToConsent = true }, }); response.ActionResultOf <RedirectResult>().Url.Should().NotBeNullOrWhiteSpace(); }); }
public void HealthProfessional_POST_PopulatesHealthProfessional() { WebAppTest(client => { var response = client.Get(CocActions.HealthProfessional("form123")).Form <HealthProfessional>(1) .SetText(m => m.Pin, "test pin") .Submit(client); ExecutorStub.Executed <AddHealthProfessional>(0).ShouldBeEquivalentTo(new AddHealthProfessional { FormId = "form123", HealthProfessional = new HealthProfessional { Pin = "test pin" }, }); response.ActionResultOf <RedirectResult>().Url.Should().NotBeNullOrWhiteSpace(); }); }
public void Evidence_POST_UploadFile() { WebAppTest(client => { var response = client.Get(CocActions.Evidence("form123")); response = response.Form <Evidence>(1) .AddFile("UploadedFile.pdf", Encoding.ASCII.GetBytes("uploaded content")) .SubmitName(CocButtons.UploadFile, client); ExecutorStub.Executed <AddEvidenceFile>(0).ShouldBeEquivalentTo(new AddEvidenceFile { FormId = "form123", Filename = "UploadedFile.pdf", Content = Encoding.ASCII.GetBytes("uploaded content"), }); response.ActionResultOf <RedirectResult>().Url.Should().Be(CocActions.Evidence("form123")); }); }
public void Declaration_POST_PopulatesDeclaration() { WebAppTest(client => { // the declaration form is now dependent on a completed ApplicantDetails, so... var detail = NewCocDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.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().NotBeNullOrWhiteSpace(); }); }