[TestCase("/some/other/page.aspx?umbPageId=1046", 1046)] //TODO: Should this match??
        public void Lookup_By_Page_Id(string urlAsString, int nodeMatch)
        {
            var routingContext = GetRoutingContext(urlAsString);
            var url            = routingContext.UmbracoContext.CleanedUmbracoUrl;  //very important to use the cleaned up umbraco url
            var docRequest     = new PublishedContentRequest(url, routingContext);
            var lookup         = new ContentFinderByPageIdQuery();

            //we need to manually stub the return output of HttpContext.Request["umbPageId"]
            var requestMock = Mock.Get(routingContext.UmbracoContext.HttpContext.Request);

            requestMock.Setup(x => x["umbPageID"])
            .Returns(routingContext.UmbracoContext.HttpContext.Request.QueryString["umbPageID"]);

            var result = lookup.TryFindContent(docRequest);

            Assert.IsTrue(result);
            Assert.AreEqual(docRequest.PublishedContent.Id, nodeMatch);
        }
Example #2
0
        [TestCase("/some/other/page.aspx?umbPageId=1046", 1046)] // TODO: Should this match??
        public async Task Lookup_By_Page_Id(string urlAsString, int nodeMatch)
        {
            var umbracoContext  = GetUmbracoContext(urlAsString);
            var httpContext     = GetHttpContextFactory(urlAsString).HttpContext;
            var publishedRouter = CreatePublishedRouter(GetUmbracoContextAccessor(umbracoContext));
            var frequest        = await publishedRouter.CreateRequestAsync(umbracoContext.CleanedUmbracoUrl);

            var mockRequestAccessor = new Mock <IRequestAccessor>();

            mockRequestAccessor.Setup(x => x.GetRequestValue("umbPageID")).Returns(httpContext.Request.QueryString["umbPageID"]);

            var lookup = new ContentFinderByPageIdQuery(mockRequestAccessor.Object, GetUmbracoContextAccessor(umbracoContext));

            var result = lookup.TryFindContent(frequest);

            Assert.IsTrue(result);
            Assert.AreEqual(frequest.PublishedContent.Id, nodeMatch);
        }
        [TestCase("/some/other/page.aspx?umbPageId=1046", 1046)] //TODO: Should this match??
        public void Lookup_By_Page_Id(string urlAsString, int nodeMatch)
        {
            var umbracoContext  = GetUmbracoContext(urlAsString);
            var publishedRouter = CreatePublishedRouter();
            var frequest        = publishedRouter.CreateRequest(umbracoContext);
            var lookup          = new ContentFinderByPageIdQuery();

            //we need to manually stub the return output of HttpContext.Request["umbPageId"]
            var requestMock = Mock.Get(umbracoContext.HttpContext.Request);

            requestMock.Setup(x => x["umbPageID"])
            .Returns(umbracoContext.HttpContext.Request.QueryString["umbPageID"]);

            var result = lookup.TryFindContent(frequest);

            Assert.IsTrue(result);
            Assert.AreEqual(frequest.PublishedContent.Id, nodeMatch);
        }
Example #4
0
    [TestCase("/some/other/page.aspx?umbPageId=1046", 1046)] // TODO: Should this match??
    public async Task Lookup_By_Page_Id(string urlAsString, int nodeMatch)
    {
        var umbracoContextAccessor = GetUmbracoContextAccessor(urlAsString);
        var umbracoContext         = umbracoContextAccessor.GetRequiredUmbracoContext();
        var publishedRouter        = CreatePublishedRouter(umbracoContextAccessor);
        var frequest = await publishedRouter.CreateRequestAsync(umbracoContext.CleanedUmbracoUrl);

        var queryStrings = HttpUtility.ParseQueryString(umbracoContext.CleanedUmbracoUrl.Query);

        var mockRequestAccessor = new Mock <IRequestAccessor>();

        mockRequestAccessor.Setup(x => x.GetRequestValue("umbPageID"))
        .Returns(queryStrings["umbPageID"]);

        var lookup = new ContentFinderByPageIdQuery(mockRequestAccessor.Object, umbracoContextAccessor);

        var result = await lookup.TryFindContent(frequest);

        Assert.IsTrue(result);
        Assert.AreEqual(frequest.PublishedContent.Id, nodeMatch);
    }