private void HostTestPage(TestCommunity testCommunity, bool secure, string page)
        {
            var data      = testCommunity.GetCommunityTestData();
            var isDeleted = IsTestCommunityDeleted;
            var community = CreateTestCommunity(data, isDeleted);

            // Hit some pages.

            AssertDefaultAndProfilePages(null);

            // Hit the landing page.

            var url = GetCommunityHostUrl(community, secure, page);

            if (url == null)
            {
                return;
            }

            Get(url);

            if (isDeleted)
            {
                // Should have been redirected to the equivalent non-vertical url.

                var redirectUrl = string.IsNullOrEmpty(page)
                    ? new ReadOnlyApplicationUrl(false, "~/")
                    : new ReadOnlyApplicationUrl(page.EndsWith(".aspx"), "~/" + (page.EndsWith(".aspx") ? page.Substring(0, page.Length - ".aspx".Length) : page));
                AssertUrl(redirectUrl);

                // No branding.

                AssertHeader(null);
            }
            else
            {
                if (data.RequiresExternalLogin)
                {
                    AssertUrl(new ReadOnlyUrl(data.ExternalLoginUrl, new ReadOnlyQueryString("returnUrl", url.AbsoluteUri)));
                }
                else
                {
                    // Check no redirection.

                    AssertUrl(GetHostUrl(url, data.Host, false));

                    // Check the contents of the page.

                    AssertHeader(data.HeaderSnippet);
                }

                // Hit the pages again.

                AssertDefaultAndProfilePages(data);
            }
        }
        private void TestRequiresExternalLogin(TestCommunity testCommunity)
        {
            var data      = testCommunity.GetCommunityTestData();
            var isDeleted = IsTestCommunityDeleted;
            var community = CreateTestCommunity(data, isDeleted);

            // Only works with a host.

            var vertical = _verticalsCommand.GetVertical(community);

            if (string.IsNullOrEmpty(vertical.Host))
            {
                return;
            }

            var url = _verticalsCommand.GetCommunityHostUrl(community, "");

            Get(url);

            if (isDeleted)
            {
                // Should have been redirected to the equivalent non-vertical url.

                var redirectUrl = new ReadOnlyApplicationUrl("~/");
                AssertUrl(redirectUrl);
            }
            else
            {
                if (vertical.RequiresExternalLogin)
                {
                    // Should have been redirected.

                    AssertUrl(new ReadOnlyUrl(vertical.ExternalLoginUrl, new ReadOnlyQueryString("returnUrl", url.AbsoluteUri)));
                }
                else
                {
                    AssertUrl(url);
                }
            }
        }
        private void TestJoinWithNewOrder(TestCommunity testCommunity, bool shouldBeJoined)
        {
            var data      = testCommunity.GetCommunityTestData();
            var community = data.CreateTestCommunity(_communitiesCommand, _verticalsCommand, _contentEngine);

            // Hit the landing page.

            var url = _verticalsCommand.GetCommunityPathUrl(community, "employers/Employer.aspx");

            Get(url);

            // Choose.

            var host      = Browser.CurrentUrl.Host;
            var chooseUrl = GetChooseUrl().AsNonReadOnly();

            chooseUrl.Host = host;
            Get(chooseUrl);

            SelectContactProduct(_productsQuery.GetProduct("Contacts40"));
            _purchaseButton.Click();
            var instanceId = GetInstanceId();

            // Join.

            var accountUrl = GetAccountUrl(instanceId).AsNonReadOnly();

            accountUrl.Host = host;
            AssertUrl(accountUrl);

            _joinLoginIdTextBox.Text         = LoginId;
            _joinPasswordTextBox.Text        = Password;
            _joinConfirmPasswordTextBox.Text = Password;
            _firstNameTextBox.Text           = FirstName;
            _lastNameTextBox.Text            = LastName;
            _emailAddressTextBox.Text        = EmailAddress;
            _phoneNumberTextBox.Text         = PhoneNumber;
            _organisationNameTextBox.Text    = OrganisationName;
            _locationTextBox.Text            = Location;
            _acceptTermsCheckBox.IsChecked   = true;
            _joinButton.Click();

            // Payment.

            var paymentUrl = GetPaymentUrl(instanceId).AsNonReadOnly();

            paymentUrl.Host = host;
            AssertUrl(paymentUrl);

            _cardNumberTextBox.Text                = CreditCardNumber;
            _cvvTextBox.Text                       = Cvv;
            _cardHolderNameTextBox.Text            = CardHolderName;
            _authoriseCreditCardCheckBox.IsChecked = true;
            _purchaseButton.Click();

            // Receipt.

            var receiptUrl = GetReceiptUrl(instanceId).AsNonReadOnly();

            receiptUrl.Host = host;
            AssertUrl(receiptUrl);

            AssertCommunity(community, LoginId, shouldBeJoined);
        }