Ejemplo n.º 1
0
 protected void TestUrl(ReadOnlyUrl expectedUrl, ReadOnlyUrl url)
 {
     AssertRedirect(url, expectedUrl);
     Get(url);
     AssertUrl(expectedUrl);
 }
Ejemplo n.º 2
0
 public string Post(ReadOnlyUrl url, NameValueCollection formVariables)
 {
     return(Browser.Post(null, GetUrlPath(url), formVariables, null));
 }
Ejemplo n.º 3
0
 protected ReadOnlyUrl GetLoginUrl(ReadOnlyUrl returnUrl)
 {
     return(GetLoginUrl(LogInUrl, returnUrl));
 }
Ejemplo n.º 4
0
 public string Head(ReadOnlyUrl url)
 {
     return(Browser.Head(null, GetUrlPath(url)));
 }
Ejemplo n.º 5
0
 protected string Get(ReadOnlyUrl url)
 {
     return(Browser.Get(null, GetUrlPath(url)));
 }
Ejemplo n.º 6
0
 public string Put(HttpStatusCode expectedStatusCode, ReadOnlyUrl url, string contentType, string content)
 {
     return(Browser.Put(expectedStatusCode, GetUrlPath(url), contentType, content));
 }
Ejemplo n.º 7
0
 public string Put(ReadOnlyUrl url)
 {
     return(Browser.Put(null, GetUrlPath(url)));
 }
Ejemplo n.º 8
0
 public void TestInitialize()
 {
     _downloadUrl = new ReadOnlyApplicationUrl(true, "~/employers/candidates/download");
 }
Ejemplo n.º 9
0
 public void TestInitialize()
 {
     _loginUrl = new ReadOnlyApplicationUrl(true, "~/employers/login");
 }
Ejemplo n.º 10
0
        private void TestPreferred(UserType userType, ReadOnlyUrl userHomeUrl, ReadOnlyUrl otherHomeUrl)
        {
            // Not set yet so all allowed through, test for popup (?) ...

            Get(userHomeUrl);
            AssertUrl(userHomeUrl);

            Get(otherHomeUrl);
            AssertUrl(otherHomeUrl);

            Get(GetIgnorePreferredUrl(userHomeUrl, false));
            AssertUrl(GetIgnorePreferredUrl(userHomeUrl, false));

            Get(GetIgnorePreferredUrl(otherHomeUrl, false));
            AssertUrl(GetIgnorePreferredUrl(otherHomeUrl, false));

            Get(GetIgnorePreferredUrl(userHomeUrl, true));
            AssertUrl(GetIgnorePreferredUrl(userHomeUrl, true));

            Get(GetIgnorePreferredUrl(otherHomeUrl, true));
            AssertUrl(GetIgnorePreferredUrl(otherHomeUrl, true));

            // Set.

            AssertJsonSuccess(PreferredUserType(userType));

            // Redirect occurs.

            Get(userHomeUrl);
            AssertUrl(userHomeUrl);

            Get(otherHomeUrl);
            AssertUrl(userHomeUrl);

            Get(GetIgnorePreferredUrl(userHomeUrl, false));
            AssertUrl(GetIgnorePreferredUrl(userHomeUrl, false));

            Get(GetIgnorePreferredUrl(otherHomeUrl, false));
            AssertUrl(userHomeUrl);

            // An explicit ignore will be allowed through with no redirect.

            Get(GetIgnorePreferredUrl(userHomeUrl, true));
            AssertUrl(GetIgnorePreferredUrl(userHomeUrl, true));

            Get(GetIgnorePreferredUrl(otherHomeUrl, true));
            AssertUrl(GetIgnorePreferredUrl(otherHomeUrl, true));

            // Remove the cookie which will revert things.

            RemoveAnonymousCookie();

            // Go again.

            Get(userHomeUrl);
            AssertUrl(userHomeUrl);

            Get(otherHomeUrl);
            AssertUrl(otherHomeUrl);

            Get(GetIgnorePreferredUrl(userHomeUrl, false));
            AssertUrl(GetIgnorePreferredUrl(userHomeUrl, false));

            Get(GetIgnorePreferredUrl(otherHomeUrl, false));
            AssertUrl(GetIgnorePreferredUrl(otherHomeUrl, false));

            Get(GetIgnorePreferredUrl(userHomeUrl, true));
            AssertUrl(GetIgnorePreferredUrl(userHomeUrl, true));

            Get(GetIgnorePreferredUrl(otherHomeUrl, true));
            AssertUrl(GetIgnorePreferredUrl(otherHomeUrl, true));
        }
Ejemplo n.º 11
0
 protected ActionResult RedirectToReturnUrl(ReadOnlyUrl defaultUrl)
 {
     return(new RedirectToUrlResult(HttpContext.GetReturnUrl(defaultUrl)));
 }
Ejemplo n.º 12
0
 public void TestInitialize()
 {
     _preferredUserTypeUrl = new ReadOnlyApplicationUrl("~/accounts/api/preferredusertype");
 }
Ejemplo n.º 13
0
 public void TestInitialize()
 {
     _apiJoinUrl = new ReadOnlyApplicationUrl(true, "~/join/api");
 }
Ejemplo n.º 14
0
 public void TestInitialize()
 {
     _homeUrl = new ReadOnlyApplicationUrl(true, "~/members/home");
 }
Ejemplo n.º 15
0
        private void AssertPagination(bool browse, int currentPage, int totalPages, ReadOnlyUrl baseUrl)
        {
            // Only show a maximum number of page links.

            int firstPage;
            int lastPage;

            if (totalPages <= MaxPages)
            {
                firstPage = 1;
                lastPage  = totalPages;
            }
            else
            {
                if (currentPage < MaxPages / 2 + 1)
                {
                    // If at left end ...

                    firstPage = 1;
                    lastPage  = MaxPages;
                }
                else if (currentPage > totalPages - MaxPages / 2)
                {
                    // If at right end ...

                    firstPage = totalPages - MaxPages + 1;
                    lastPage  = totalPages;
                }
                else
                {
                    // If in the middle ...

                    firstPage = currentPage < MaxPages / 2 + 1 ? 1 : currentPage - MaxPages / 2;
                    lastPage  = currentPage > totalPages - MaxPages / 2 ? totalPages : currentPage + MaxPages / 2;
                }
            }

            // First, previous, next, last.

            var firstANode   = Browser.CurrentHtml.DocumentNode.SelectSingleNode(string.Format("//a[@class='page first secondary{0}']", currentPage != 1 ? " active" : ""));
            var firstDivNode = Browser.CurrentHtml.DocumentNode.SelectSingleNode(string.Format("//div[@class='page first secondary{0}']", currentPage != 1 ? "" : " active"));

            var previousANode   = Browser.CurrentHtml.DocumentNode.SelectSingleNode(string.Format("//a[@class='page previous{0}']", currentPage != 1 ? " active" : ""));
            var previousDivNode = Browser.CurrentHtml.DocumentNode.SelectSingleNode(string.Format("//div[@class='page previous{0}']", currentPage != 1 ? "" : " active"));

            var nextANode   = Browser.CurrentHtml.DocumentNode.SelectSingleNode(string.Format("//a[@class='page next{0}']", currentPage != totalPages ? " active" : ""));
            var nextDivNode = Browser.CurrentHtml.DocumentNode.SelectSingleNode(string.Format("//div[@class='page next{0}']", currentPage != totalPages ? "" : " active"));

            var lastANode   = Browser.CurrentHtml.DocumentNode.SelectSingleNode(string.Format("//a[@class='page last secondary{0}']", currentPage != totalPages ? " active" : ""));
            var lastDivNode = Browser.CurrentHtml.DocumentNode.SelectSingleNode(string.Format("//div[@class='page last secondary{0}']", currentPage != totalPages ? "" : " active"));

            Assert.IsNotNull(firstDivNode);
            Assert.IsNotNull(previousDivNode);
            Assert.IsNotNull(nextDivNode);
            Assert.IsNotNull(lastDivNode);

            Assert.IsNotNull(firstANode);
            Assert.IsNotNull(previousANode);
            Assert.IsNotNull(nextANode);
            Assert.IsNotNull(lastANode);

            AssertPaginationNode(browse, 1, baseUrl, "First", firstANode);
            AssertPaginationNode(browse, currentPage - 1, baseUrl, "<\xA0Previous", previousANode);

            AssertPaginationNode(1, "First", firstDivNode);
            AssertPaginationNode(currentPage - 1, "<\xA0Previous", previousDivNode);

            AssertPaginationNode(browse, currentPage + 1, baseUrl, "Next\xA0>", nextANode);
            AssertPaginationNode(browse, totalPages, baseUrl, "Last", lastANode);

            AssertPaginationNode(currentPage + 1, "Next\xA0>", nextDivNode);
            AssertPaginationNode(totalPages, "Last", lastDivNode);

            // Ellipsis.

            if (firstPage > 1)
            {
                Assert.IsNotNull(Browser.CurrentHtml.DocumentNode.SelectSingleNode("//span[@class='pagination-ellipsis left active']"));
                Assert.IsNull(Browser.CurrentHtml.DocumentNode.SelectSingleNode("//span[@class='pagination-ellipsis left']"));
            }
            else
            {
                Assert.IsNull(Browser.CurrentHtml.DocumentNode.SelectSingleNode("//span[@class='pagination-ellipsis left active']"));
                Assert.IsNotNull(Browser.CurrentHtml.DocumentNode.SelectSingleNode("//span[@class='pagination-ellipsis left']"));
            }

            if (lastPage < totalPages)
            {
                Assert.IsNotNull(Browser.CurrentHtml.DocumentNode.SelectSingleNode("//span[@class='pagination-ellipsis right active']"));
                Assert.IsNull(Browser.CurrentHtml.DocumentNode.SelectSingleNode("//span[@class='pagination-ellipsis right']"));
            }
            else
            {
                Assert.IsNull(Browser.CurrentHtml.DocumentNode.SelectSingleNode("//span[@class='pagination-ellipsis right active']"));
                Assert.IsNotNull(Browser.CurrentHtml.DocumentNode.SelectSingleNode("//span[@class='pagination-ellipsis right']"));
            }

            // Pages.

            var nodes          = Browser.CurrentHtml.DocumentNode.SelectNodes("//a[@class='page active']");
            var currentANode   = Browser.CurrentHtml.DocumentNode.SelectNodes("//a[@class='page']");
            var currentDivNode = Browser.CurrentHtml.DocumentNode.SelectNodes("//div[@class='page current']");

            Assert.IsNotNull(currentANode);
            Assert.IsNotNull(currentDivNode);
            Assert.IsNotNull(nodes);
            Assert.AreEqual(1, currentDivNode.Count);
            Assert.AreEqual(1, currentANode.Count);
            Assert.AreEqual(lastPage - firstPage + 1, nodes.Count + currentANode.Count);

            var index         = 0;
            var currentOffset = 0;

            for (var page = firstPage; page <= lastPage; ++page)
            {
                if (page == currentPage)
                {
                    AssertCurrentPaginationNode(page.ToString(CultureInfo.InvariantCulture), currentANode[0]);
                    currentOffset = 1;
                }
                else
                {
                    if (browse)
                    {
                        AssertPaginationNode(true, page, baseUrl, page.ToString(CultureInfo.InvariantCulture), nodes[index - currentOffset]);
                    }
                    else
                    {
                        AssertPaginationNode(page, page.ToString(CultureInfo.InvariantCulture), nodes[index - currentOffset]);
                    }
                }
                ++index;
            }
        }
Ejemplo n.º 16
0
 public void TestInitialize()
 {
     Resolve <IDbConnectionFactory>().DeleteAllTestData();
     _photoUrl = new ReadOnlyApplicationUrl("~/employers/candidates/photo");
     _loginUrl = new ReadOnlyApplicationUrl(true, "~/employers/login");
 }
Ejemplo n.º 17
0
 public void TestInitialize()
 {
     _sendUrl = new ReadOnlyApplicationUrl(true, "~/employers/candidates/api/sendresumes");
     _emailServer.ClearEmails();
 }
Ejemplo n.º 18
0
 public void TestInitialize()
 {
     Resolve <IDbConnectionFactory>().DeleteAllTestData();
     _manageCandidatesUrl = new ReadOnlyApplicationUrl("~/employers/candidates/manage/");
 }
Ejemplo n.º 19
0
 public string Put(ReadOnlyUrl url, string contentType, string content)
 {
     return(Browser.Put(null, GetUrlPath(url), contentType, content));
 }
Ejemplo n.º 20
0
 public void UnlockTestsInitialize()
 {
     _baseUnlockUrl = new ReadOnlyApplicationUrl(true, "~/v1/employers/candidates/");
 }
Ejemplo n.º 21
0
 public string Delete(ReadOnlyUrl url)
 {
     return(Browser.Delete(null, GetUrlPath(url)));
 }
Ejemplo n.º 22
0
        public void TestInitialize()
        {
            ClearSearchIndexes();

            _saveSearchUrl = new ReadOnlyApplicationUrl("~/employers/searches/api/save");
        }
Ejemplo n.º 23
0
 protected string Get(HttpStatusCode expectedStatusCode, ReadOnlyUrl url)
 {
     return(Browser.Get(expectedStatusCode, GetUrlPath(url)));
 }
Ejemplo n.º 24
0
 public void TestInitialize()
 {
     _recentSearchesUrl = new ReadOnlyApplicationUrl(true, "~/members/searches/recent");
 }
Ejemplo n.º 25
0
 public string Post(HttpStatusCode expectedStatusCode, ReadOnlyUrl url, NameValueCollection formVariables)
 {
     return(Browser.Post(expectedStatusCode, GetUrlPath(url), formVariables, null));
 }
Ejemplo n.º 26
0
 public void TestInitialize()
 {
     Browser.UseMobileUserAgent = true;
     _mobileFolderUrl           = new ReadOnlyApplicationUrl(true, "~/members/jobs/folders/mobile");
 }
Ejemplo n.º 27
0
 public string Post(HttpStatusCode expectedStatusCode, ReadOnlyUrl url)
 {
     return(Browser.Post(expectedStatusCode, GetUrlPath(url)));
 }
Ejemplo n.º 28
0
        public void TestInitialize()
        {
            _resolveLocationUrl = new ReadOnlyApplicationUrl("~/api/location/resolve");

            _newZealand = _locationQuery.GetCountry("New Zealand");
        }
Ejemplo n.º 29
0
 protected ReadOnlyUrl GetEmployerLoginUrl(ReadOnlyUrl returnUrl)
 {
     return(GetLoginUrl(EmployerLogInUrl, returnUrl));
 }
Ejemplo n.º 30
0
 protected void TestUrl(ReadOnlyUrl url)
 {
     AssertNoRedirect(url);
     Get(url);
     AssertUrl(url);
 }