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 Options_POST_ErrorsAreDisplayed()
        {
            WebAppTest(client =>
            {
                ExecutorStub.SetupCommand <AddOptions, NextSection>((cmd, def) => { throw new DomainException("simulated logic error"); });

                var response = client.Get(CocActions.Options("form123")).Form <Options>(1)
                               .Submit(client, r => r.SetExpectedResponse(HttpStatusCode.OK));

                response.Doc.Find(".validation-summary-errors").Should().NotBeNull();
            });
        }
        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 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();
            });
        }