public void Lookup_By_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 ContentFinderByIdPath(); var result = lookup.TryFindContent(docRequest); Assert.IsTrue(result); Assert.AreEqual(docRequest.PublishedContent.Id, nodeMatch); }
public void Lookup_By_Id(string urlAsString, int nodeMatch) { var umbracoContext = GetUmbracoContext(urlAsString); var publishedRouter = CreatePublishedRouter(); var frequest = publishedRouter.CreateRequest(umbracoContext); var lookup = new ContentFinderByIdPath(Factory.GetInstance <IUmbracoSettingsSection>().WebRouting, Logger); var result = lookup.TryFindContent(frequest); Assert.IsTrue(result); Assert.AreEqual(frequest.PublishedContent.Id, nodeMatch); }
public async Task Lookup_By_Id(string urlAsString, int nodeMatch) { var umbracoContext = GetUmbracoContext(urlAsString); var publishedRouter = CreatePublishedRouter(GetUmbracoContextAccessor(umbracoContext)); var frequest = await publishedRouter.CreateRequestAsync(umbracoContext.CleanedUmbracoUrl); var webRoutingSettings = new WebRoutingSettings(); var lookup = new ContentFinderByIdPath(Microsoft.Extensions.Options.Options.Create(webRoutingSettings), LoggerFactory.CreateLogger <ContentFinderByIdPath>(), Factory.GetRequiredService <IRequestAccessor>(), GetUmbracoContextAccessor(umbracoContext)); var result = lookup.TryFindContent(frequest); Assert.IsTrue(result); Assert.AreEqual(frequest.PublishedContent.Id, nodeMatch); }
public async Task Lookup_By_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 webRoutingSettings = new WebRoutingSettings(); var lookup = new ContentFinderByIdPath( Mock.Of <IOptionsMonitor <WebRoutingSettings> >(x => x.CurrentValue == webRoutingSettings), Mock.Of <ILogger <ContentFinderByIdPath> >(), Mock.Of <IRequestAccessor>(), umbracoContextAccessor); var result = await lookup.TryFindContent(frequest); Assert.IsTrue(result); Assert.AreEqual(frequest.PublishedContent.Id, nodeMatch); }