[TestCase("http://domain1.com/en/bar/nil", "en-US", 100111)]      // ok, alias includes "en/"
        public void Lookup_By_Url_Alias_And_Domain(string inputUrl, string expectedCulture, int expectedNode)
        {
            //SetDomains1();

            var umbracoContext  = GetUmbracoContext(inputUrl);
            var publishedRouter = CreatePublishedRouter();
            var request         = publishedRouter.CreateRequest(umbracoContext);

            // must lookup domain
            publishedRouter.FindDomain(request);

            if (expectedNode > 0)
            {
                Assert.AreEqual(expectedCulture, request.Culture.Name);
            }

            var finder = new ContentFinderByUrlAlias(Logger);
            var result = finder.TryFindContent(request);

            if (expectedNode > 0)
            {
                Assert.IsTrue(result);
                Assert.AreEqual(request.PublishedContent.Id, expectedNode);
            }
            else
            {
                Assert.IsFalse(result);
            }
        }
        [TestCase("http://domain1.com/en/bar/nil", "en-US", 100111)]      // ok, alias includes "en/"
        public async Task Lookup_By_Url_Alias_And_Domain(string inputUrl, string expectedCulture, int expectedNode)
        {
            //SetDomains1();
            var umbracoContextAccessor = GetUmbracoContextAccessor(inputUrl);
            var publishedRouter        = CreatePublishedRouter(umbracoContextAccessor);
            var umbracoContext         = umbracoContextAccessor.GetRequiredUmbracoContext();

            var request = await publishedRouter.CreateRequestAsync(umbracoContext.CleanedUmbracoUrl);

            // must lookup domain
            publishedRouter.FindDomain(request);

            if (expectedNode > 0)
            {
                Assert.AreEqual(expectedCulture, request.Culture);
            }

            var finder = new ContentFinderByUrlAlias(Mock.Of <ILogger <ContentFinderByUrlAlias> >(), Mock.Of <IPublishedValueFallback>(), VariationContextAccessor, umbracoContextAccessor);
            var result = finder.TryFindContent(request);

            if (expectedNode > 0)
            {
                Assert.IsTrue(result);
                Assert.AreEqual(request.PublishedContent.Id, expectedNode);
            }
            else
            {
                Assert.IsFalse(result);
            }
        }
    public async Task Lookup_By_Url_Alias(
        string relativeUrl,
        int nodeMatch,
        [Frozen] IPublishedContentCache publishedContentCache,
        [Frozen] IUmbracoContextAccessor umbracoContextAccessor,
        [Frozen] IUmbracoContext umbracoContext,
        [Frozen] IVariationContextAccessor variationContextAccessor,
        IFileService fileService,
        ContentFinderByUrlAlias sut,
        IPublishedContent[] rootContents,
        IPublishedProperty urlProperty)
    {
        // Arrange
        var absoluteUrl      = "http://localhost" + relativeUrl;
        var variationContext = new VariationContext();

        var contentItem = rootContents[0];

        Mock.Get(umbracoContextAccessor).Setup(x => x.TryGetUmbracoContext(out umbracoContext)).Returns(true);
        Mock.Get(umbracoContext).Setup(x => x.Content).Returns(publishedContentCache);
        Mock.Get(publishedContentCache).Setup(x => x.GetAtRoot(null)).Returns(rootContents);
        Mock.Get(contentItem).Setup(x => x.Id).Returns(nodeMatch);
        Mock.Get(contentItem).Setup(x => x.GetProperty(Constants.Conventions.Content.UrlAlias)).Returns(urlProperty);
        Mock.Get(urlProperty).Setup(x => x.GetValue(null, null)).Returns(relativeUrl);

        Mock.Get(variationContextAccessor).Setup(x => x.VariationContext).Returns(variationContext);
        var publishedRequestBuilder = new PublishedRequestBuilder(new Uri(absoluteUrl, UriKind.Absolute), fileService);

        // Act
        var result = await sut.TryFindContent(publishedRequestBuilder);

        Assert.IsTrue(result);
        Assert.AreEqual(publishedRequestBuilder.PublishedContent.Id, nodeMatch);
    }
        [TestCase("http://domain1.com/en/bar/nil", "en-US", 100111)]      // ok, alias includes "en/"
        public void Lookup_By_Url_Alias_And_Domain(string inputUrl, string expectedCulture, int expectedNode)
        {
            SetDomains1();

            var routingContext = GetRoutingContext(inputUrl);
            var url            = routingContext.UmbracoContext.CleanedUmbracoUrl; //very important to use the cleaned up umbraco url
            var pcr            = new PublishedContentRequest(url, routingContext);

            // must lookup domain
            pcr.Engine.FindDomain();

            if (expectedNode > 0)
            {
                Assert.AreEqual(expectedCulture, pcr.Culture.Name);
            }

            var finder = new ContentFinderByUrlAlias();
            var result = finder.TryFindContent(pcr);

            if (expectedNode > 0)
            {
                Assert.IsTrue(result);
                Assert.AreEqual(pcr.PublishedContent.Id, expectedNode);
            }
            else
            {
                Assert.IsFalse(result);
            }
        }
        public void Lookup_By_Url_Alias(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 ContentFinderByUrlAlias();

            var result = lookup.TryFindContent(docRequest);

            Assert.IsTrue(result);
            Assert.AreEqual(docRequest.PublishedContent.Id, nodeMatch);
        }
        public void Lookup_By_Url_Alias(string urlAsString, int nodeMatch)
        {
            var umbracoContext  = GetUmbracoContext(urlAsString);
            var publishedRouter = CreatePublishedRouter();
            var frequest        = publishedRouter.CreateRequest(umbracoContext);
            var lookup          = new ContentFinderByUrlAlias(Logger);

            var result = lookup.TryFindContent(frequest);

            Assert.IsTrue(result);
            Assert.AreEqual(frequest.PublishedContent.Id, nodeMatch);
        }
        public async Task Lookup_By_Url_Alias(string urlAsString, int nodeMatch)
        {
            var umbracoContext  = GetUmbracoContext(urlAsString);
            var publishedRouter = CreatePublishedRouter(GetUmbracoContextAccessor(umbracoContext));
            var frequest        = await publishedRouter.CreateRequestAsync(umbracoContext.CleanedUmbracoUrl);

            var lookup =
                new ContentFinderByUrlAlias(LoggerFactory.CreateLogger <ContentFinderByUrlAlias>(), Mock.Of <IPublishedValueFallback>(), VariationContextAccessor, GetUmbracoContextAccessor(umbracoContext));

            var result = lookup.TryFindContent(frequest);

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