V17 - Content Finder unit tests cleanup (#19989)
* Removing ContentFinderByUrlAndTemplateTests.cs and dependencies * Removing ContentFinderByAliasTests.cs * Removing ContentFinderByAliasWithDomainsTests.cs * Removing ContentFinderByIdentifierTestsBase.cs * Removing ContentFinderByIdTests.cs * Fixing ContentFinderByKeyTests.cs & ContentFinderByPageIdQueryTests.cs to work with new code * Removing ContentFinderByUrlTests.cs & ContentFinderByUrlWithDomainsTests.cs * Fixing ContentFinderByPageIdQueryTests.cs to actually test the result rather than force the result * Removing comment and adding test scenario
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
// using System.Threading.Tasks;
|
||||
// using Microsoft.Extensions.Logging;
|
||||
// using Moq;
|
||||
// using NUnit.Framework;
|
||||
// using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
// using Umbraco.Cms.Core.Routing;
|
||||
// using Umbraco.Extensions;
|
||||
//
|
||||
// namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing;
|
||||
//
|
||||
// // TODO: We should be able to decouple this from the base db tests since we're just mocking the services now
|
||||
// FIXME: Reintroduce if relevant
|
||||
// [TestFixture]
|
||||
// public class ContentFinderByAliasTests : UrlRoutingTestBase
|
||||
// {
|
||||
// [TestCase("/this/is/my/alias", 1001)]
|
||||
// [TestCase("/anotheralias", 1001)]
|
||||
// [TestCase("/page2/alias", 10011)]
|
||||
// [TestCase("/2ndpagealias", 10011)]
|
||||
// [TestCase("/only/one/alias", 100111)]
|
||||
// [TestCase("/ONLY/one/Alias", 100111)]
|
||||
// [TestCase("/alias43", 100121)]
|
||||
// public async Task Lookup_By_Url_Alias(string urlAsString, int nodeMatch)
|
||||
// {
|
||||
// var umbracoContextAccessor = GetUmbracoContextAccessor(urlAsString);
|
||||
// var publishedRouter = CreatePublishedRouter(umbracoContextAccessor);
|
||||
// var umbracoContext = umbracoContextAccessor.GetRequiredUmbracoContext();
|
||||
//
|
||||
// var frequest = await publishedRouter.CreateRequestAsync(umbracoContext.CleanedUmbracoUrl);
|
||||
// var lookup =
|
||||
// new ContentFinderByUrlAlias(Mock.Of<ILogger<ContentFinderByUrlAlias>>(), Mock.Of<IPublishedValueFallback>(), VariationContextAccessor, umbracoContextAccessor);
|
||||
//
|
||||
// var result = await lookup.TryFindContent(frequest);
|
||||
//
|
||||
// Assert.IsTrue(result);
|
||||
// Assert.AreEqual(frequest.PublishedContent.Id, nodeMatch);
|
||||
// }
|
||||
// }
|
||||
@@ -1,59 +0,0 @@
|
||||
// using System.Threading.Tasks;
|
||||
// using Microsoft.Extensions.Logging;
|
||||
// using Moq;
|
||||
// using NUnit.Framework;
|
||||
// using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
// using Umbraco.Cms.Core.Routing;
|
||||
// using Umbraco.Extensions;
|
||||
//
|
||||
// namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing;
|
||||
//
|
||||
// FIXME: Reintroduce if relevant
|
||||
// [TestFixture]
|
||||
// public class ContentFinderByAliasWithDomainsTests : UrlRoutingTestBase
|
||||
// {
|
||||
// [TestCase("http://domain1.com/this/is/my/alias", "de-DE", -1001)] // alias to domain's page fails - no alias on domain's home
|
||||
// [TestCase("http://domain1.com/page2/alias", "de-DE", 10011)] // alias to sub-page works
|
||||
// [TestCase("http://domain1.com/en/flux", "en-US", -10011)] // alias to domain's page fails - no alias on domain's home
|
||||
// [TestCase("http://domain1.com/endanger", "de-DE", 10011)] // alias to sub-page works, even with "en..."
|
||||
// [TestCase("http://domain1.com/en/endanger", "en-US", -10011)] // no
|
||||
// [TestCase("http://domain1.com/only/one/alias", "de-DE", 100111)] // ok
|
||||
// [TestCase("http://domain1.com/entropy", "de-DE", 100111)] // ok
|
||||
// [TestCase("http://domain1.com/bar/foo", "de-DE", 100111)] // ok
|
||||
// [TestCase("http://domain1.com/en/bar/foo", "en-US", -100111)] // no, alias must include "en/"
|
||||
// [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.FindAndSetDomain(request);
|
||||
//
|
||||
// if (expectedNode > 0)
|
||||
// {
|
||||
// Assert.AreEqual(expectedCulture, request.Culture);
|
||||
// }
|
||||
//
|
||||
// var finder = new ContentFinderByUrlAlias(
|
||||
// Mock.Of<ILogger<ContentFinderByUrlAlias>>(),
|
||||
// Mock.Of<IPublishedValueFallback>(),
|
||||
// VariationContextAccessor,
|
||||
// umbracoContextAccessor);
|
||||
// var result = await finder.TryFindContent(request);
|
||||
//
|
||||
// if (expectedNode > 0)
|
||||
// {
|
||||
// Assert.IsTrue(result);
|
||||
// Assert.AreEqual(request.PublishedContent.Id, expectedNode);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Assert.IsFalse(result);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -1,51 +0,0 @@
|
||||
// using Microsoft.Extensions.Logging;
|
||||
// using Microsoft.Extensions.Options;
|
||||
// using Moq;
|
||||
// using NUnit.Framework;
|
||||
// using Umbraco.Cms.Core.Configuration.Models;
|
||||
// using Umbraco.Cms.Core.Routing;
|
||||
// using Umbraco.Cms.Core.Web;
|
||||
// using Umbraco.Extensions;
|
||||
//
|
||||
// FIXME: Reintroduce if relevant
|
||||
// namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing;
|
||||
//
|
||||
// [TestFixture]
|
||||
// public class ContentFinderByIdTests : ContentFinderByIdentifierTestsBase
|
||||
// {
|
||||
// [SetUp]
|
||||
// public override void Setup()
|
||||
// {
|
||||
// base.Setup();
|
||||
// }
|
||||
//
|
||||
// [TestCase("/1046", 1046, true)]
|
||||
// [TestCase("/1046", 1047, false)]
|
||||
// public async Task Lookup_By_Id(string urlAsString, int nodeId, bool shouldSucceed)
|
||||
// {
|
||||
// PopulateCache(nodeId, Guid.NewGuid());
|
||||
//
|
||||
// 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.AreEqual(shouldSucceed, result);
|
||||
// if (shouldSucceed)
|
||||
// {
|
||||
// Assert.AreEqual(frequest.PublishedContent!.Id, nodeId);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Assert.IsNull(frequest.PublishedContent);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -1,59 +0,0 @@
|
||||
// using Umbraco.Cms.Core.Models;
|
||||
// using Umbraco.Cms.Tests.Common.Builders;
|
||||
// using Umbraco.Cms.Tests.Common.Builders.Extensions;
|
||||
// using Umbraco.Cms.Tests.UnitTests.TestHelpers;
|
||||
//
|
||||
// namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing;
|
||||
//
|
||||
// FIXME: Reintroduce if relevant
|
||||
// public abstract class ContentFinderByIdentifierTestsBase : PublishedSnapshotServiceTestBase
|
||||
// {
|
||||
// protected void PopulateCache(int nodeId, Guid nodeKey)
|
||||
// {
|
||||
// var dataTypes = GetDefaultDataTypes().Select(dt => dt as IDataType).ToArray();
|
||||
// var propertyDataTypes = new Dictionary<string, IDataType>
|
||||
// {
|
||||
// // we only have one data type for this test which will be resolved with string empty.
|
||||
// [string.Empty] = dataTypes[0],
|
||||
// };
|
||||
// IContentType contentType1 = new ContentType(ShortStringHelper, -1);
|
||||
//
|
||||
// var rootData = new ContentDataBuilder()
|
||||
// .WithName("Page" + Guid.NewGuid())
|
||||
// .Build(ShortStringHelper, propertyDataTypes, contentType1, "alias");
|
||||
//
|
||||
// var root = ContentNodeKitBuilder.CreateWithContent(
|
||||
// contentType1.Id,
|
||||
// 9876,
|
||||
// "-1,9876",
|
||||
// draftData: rootData,
|
||||
// publishedData: rootData);
|
||||
//
|
||||
// var parentData = new ContentDataBuilder()
|
||||
// .WithName("Page" + Guid.NewGuid())
|
||||
// .Build();
|
||||
//
|
||||
// var parent = ContentNodeKitBuilder.CreateWithContent(
|
||||
// contentType1.Id,
|
||||
// 5432,
|
||||
// "-1,9876,5432",
|
||||
// parentContentId: 9876,
|
||||
// draftData: parentData,
|
||||
// publishedData: parentData);
|
||||
//
|
||||
// var contentData = new ContentDataBuilder()
|
||||
// .WithName("Page" + Guid.NewGuid())
|
||||
// .Build();
|
||||
//
|
||||
// var content = ContentNodeKitBuilder.CreateWithContent(
|
||||
// contentType1.Id,
|
||||
// nodeId,
|
||||
// "-1,9876,5432," + nodeId,
|
||||
// parentContentId: 5432,
|
||||
// draftData: contentData,
|
||||
// publishedData: contentData,
|
||||
// uid: nodeKey);
|
||||
//
|
||||
// InitializedCache(new[] { root, parent, content }, [contentType1], dataTypes);
|
||||
// }
|
||||
// }
|
||||
@@ -1,53 +1,58 @@
|
||||
// using Microsoft.Extensions.Logging;
|
||||
// using Microsoft.Extensions.Options;
|
||||
// using Moq;
|
||||
// using NUnit.Framework;
|
||||
// using Umbraco.Cms.Core.Configuration.Models;
|
||||
// using Umbraco.Cms.Core.Routing;
|
||||
// using Umbraco.Cms.Core.Web;
|
||||
// using Umbraco.Extensions;
|
||||
//
|
||||
// namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing;
|
||||
//
|
||||
// FIXME: Reintroduce if relevant
|
||||
// [TestFixture]
|
||||
// public class ContentFinderByKeyTests : ContentFinderByIdentifierTestsBase
|
||||
// {
|
||||
// [SetUp]
|
||||
// public override void Setup()
|
||||
// {
|
||||
// base.Setup();
|
||||
// }
|
||||
//
|
||||
// [TestCase("/1598901d-ebbe-4996-b7fb-6a6cbac13a62", "1598901d-ebbe-4996-b7fb-6a6cbac13a62", true)]
|
||||
// [TestCase("/1598901d-ebbe-4996-b7fb-6a6cbac13a62", "a383f6ed-cc54-46f1-a577-33f42e7214de", false)]
|
||||
// public async Task Lookup_By_Key(string urlAsString, string nodeKeyString, bool shouldSucceed)
|
||||
// {
|
||||
// var nodeKey = Guid.Parse(nodeKeyString);
|
||||
//
|
||||
// PopulateCache(9999, nodeKey);
|
||||
//
|
||||
// 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 ContentFinderByKeyPath(
|
||||
// Mock.Of<IOptionsMonitor<WebRoutingSettings>>(x => x.CurrentValue == webRoutingSettings),
|
||||
// Mock.Of<ILogger<ContentFinderByKeyPath>>(),
|
||||
// Mock.Of<IRequestAccessor>(),
|
||||
// umbracoContextAccessor);
|
||||
//
|
||||
// var result = await lookup.TryFindContent(frequest);
|
||||
//
|
||||
// Assert.AreEqual(shouldSucceed, result);
|
||||
// if (shouldSucceed)
|
||||
// {
|
||||
// Assert.AreEqual(frequest.PublishedContent!.Key, nodeKey);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Assert.IsNull(frequest.PublishedContent);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
using AutoFixture.NUnit3;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
using Umbraco.Cms.Core.Routing;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Web;
|
||||
using Umbraco.Cms.Tests.UnitTests.AutoFixture;
|
||||
|
||||
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing;
|
||||
|
||||
[TestFixture]
|
||||
public class ContentFinderByKeyTests
|
||||
{
|
||||
[Test]
|
||||
[InlineAutoMoqData("/1598901d-ebbe-4996-b7fb-6a6cbac13a62", "1598901d-ebbe-4996-b7fb-6a6cbac13a62", true)]
|
||||
[InlineAutoMoqData("/1598901d-ebbe-4996-b7fb-6a6cbac13a62", "9E966427-25AB-4909-B403-DED1F421D1A7", false)]
|
||||
public async Task Lookup_By_Key(
|
||||
string urlAsString,
|
||||
string nodeKeyString,
|
||||
bool shouldSucceed,
|
||||
[Frozen] IPublishedContent publishedContent,
|
||||
[Frozen] IUmbracoContextAccessor umbracoContextAccessor,
|
||||
[Frozen] IUmbracoContext umbracoContext,
|
||||
IFileService fileService)
|
||||
{
|
||||
var absoluteUrl = "http://localhost" + urlAsString;
|
||||
|
||||
Guid nodeKey = Guid.Parse(nodeKeyString);
|
||||
|
||||
Mock.Get(umbracoContextAccessor).Setup(x => x.TryGetUmbracoContext(out umbracoContext)).Returns(true);
|
||||
Mock.Get(umbracoContext).Setup(x => x.Content.GetById(nodeKey)).Returns(publishedContent);
|
||||
Mock.Get(publishedContent).Setup(x => x.Key).Returns(nodeKey);
|
||||
|
||||
var publishedRequestBuilder = new PublishedRequestBuilder(new Uri(absoluteUrl, UriKind.Absolute), fileService);
|
||||
var webRoutingSettings = new WebRoutingSettings();
|
||||
|
||||
var sut = new ContentFinderByKeyPath(
|
||||
Mock.Of<IOptionsMonitor<WebRoutingSettings>>(x => x.CurrentValue == webRoutingSettings),
|
||||
Mock.Of<ILogger<ContentFinderByKeyPath>>(),
|
||||
Mock.Of<IRequestAccessor>(),
|
||||
umbracoContextAccessor);
|
||||
|
||||
await sut.TryFindContent(publishedRequestBuilder);
|
||||
|
||||
if (shouldSucceed)
|
||||
{
|
||||
Assert.AreEqual(publishedRequestBuilder.PublishedContent!.Key, nodeKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.AreNotEqual(publishedRequestBuilder.PublishedContent!.Key, nodeKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +1,49 @@
|
||||
// using System.Collections.Generic;
|
||||
// using System.Linq;
|
||||
// using System.Threading.Tasks;
|
||||
// using System.Web;
|
||||
// using Moq;
|
||||
// using NUnit.Framework;
|
||||
// using Umbraco.Cms.Core.Routing;
|
||||
// using Umbraco.Cms.Core.Web;
|
||||
// using Umbraco.Cms.Infrastructure.PublishedCache;
|
||||
// using Umbraco.Cms.Tests.Common.Published;
|
||||
// using Umbraco.Cms.Tests.UnitTests.TestHelpers;
|
||||
// using Umbraco.Extensions;
|
||||
//
|
||||
// namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing;
|
||||
//
|
||||
// FIXME: Reintroduce if relevant
|
||||
// [TestFixture]
|
||||
// public class ContentFinderByPageIdQueryTests : PublishedSnapshotServiceTestBase
|
||||
// {
|
||||
// [SetUp]
|
||||
// public override void Setup()
|
||||
// {
|
||||
// base.Setup();
|
||||
//
|
||||
// var xml = PublishedContentXml.BaseWebTestXml(1234);
|
||||
//
|
||||
// IEnumerable<ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
|
||||
// xml,
|
||||
// TestHelper.ShortStringHelper,
|
||||
// out var contentTypes,
|
||||
// out var dataTypes).ToList();
|
||||
//
|
||||
// InitializedCache(kits, contentTypes, dataTypes);
|
||||
// }
|
||||
//
|
||||
// [TestCase("/?umbPageId=1046", 1046)]
|
||||
// [TestCase("/?UMBPAGEID=1046", 1046)]
|
||||
// [TestCase("/default.aspx?umbPageId=1046", 1046)] // TODO: Should this match??
|
||||
// [TestCase("/some/other/page?umbPageId=1046", 1046)] // TODO: Should this match??
|
||||
// [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);
|
||||
// }
|
||||
// }
|
||||
using System.Web;
|
||||
using AutoFixture.NUnit3;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
using Umbraco.Cms.Core.Routing;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Web;
|
||||
using Umbraco.Cms.Tests.UnitTests.AutoFixture;
|
||||
|
||||
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing;
|
||||
|
||||
[TestFixture]
|
||||
public class ContentFinderByPageIdQueryTests
|
||||
{
|
||||
[Test]
|
||||
[InlineAutoMoqData("/?umbPageId=1046", 1046)]
|
||||
[InlineAutoMoqData("/?UMBPAGEID=1046", 1046)]
|
||||
public async Task Lookup_By_Page_Id(
|
||||
string urlAsString,
|
||||
int nodeMatch,
|
||||
[Frozen] IPublishedContent publishedContent,
|
||||
[Frozen] IUmbracoContextAccessor umbracoContextAccessor,
|
||||
[Frozen] IUmbracoContext umbracoContext,
|
||||
[Frozen] IRequestAccessor requestAccessor,
|
||||
IFileService fileService)
|
||||
{
|
||||
var absoluteUrl = "http://localhost" + urlAsString;
|
||||
|
||||
Mock.Get(umbracoContextAccessor).Setup(x => x.TryGetUmbracoContext(out umbracoContext)).Returns(true);
|
||||
Mock.Get(umbracoContext).Setup(x => x.Content.GetById(nodeMatch)).Returns(publishedContent);
|
||||
Mock.Get(umbracoContext).Setup(x => x.CleanedUmbracoUrl)
|
||||
.Returns(new Uri(absoluteUrl, UriKind.Absolute));
|
||||
Mock.Get(publishedContent).Setup(x => x.Id).Returns(nodeMatch);
|
||||
|
||||
var queryStrings = HttpUtility.ParseQueryString(umbracoContext.CleanedUmbracoUrl.Query);
|
||||
Mock.Get(requestAccessor).Setup(x => x.GetRequestValue("umbPageID"))
|
||||
.Returns(queryStrings["umbPageID"]);
|
||||
|
||||
var publishedRequestBuilder = new PublishedRequestBuilder(new Uri(absoluteUrl, UriKind.Absolute), fileService);
|
||||
|
||||
var lookup = new ContentFinderByPageIdQuery(requestAccessor, umbracoContextAccessor);
|
||||
|
||||
var result = await lookup.TryFindContent(publishedRequestBuilder);
|
||||
|
||||
Assert.IsTrue(result);
|
||||
Assert.AreEqual(publishedRequestBuilder.PublishedContent!.Id, nodeMatch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
// using System.Collections.Generic;
|
||||
// using System.Linq;
|
||||
// using System.Threading.Tasks;
|
||||
// using Microsoft.Extensions.Logging;
|
||||
// using Microsoft.Extensions.Options;
|
||||
// using Moq;
|
||||
// using NUnit.Framework;
|
||||
// using Umbraco.Cms.Core.Configuration.Models;
|
||||
// using Umbraco.Cms.Core.Models;
|
||||
// using Umbraco.Cms.Core.Routing;
|
||||
// using Umbraco.Cms.Core.Services;
|
||||
// using Umbraco.Cms.Infrastructure.PublishedCache;
|
||||
// using Umbraco.Cms.Tests.Common.Published;
|
||||
// using Umbraco.Cms.Tests.UnitTests.TestHelpers;
|
||||
// using Umbraco.Extensions;
|
||||
//
|
||||
// namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing;
|
||||
//
|
||||
// FIXME: Reintroduce if relevant
|
||||
// [TestFixture]
|
||||
// public class ContentFinderByUrlAndTemplateTests : PublishedSnapshotServiceTestBase
|
||||
// {
|
||||
// [SetUp]
|
||||
// public override void Setup()
|
||||
// {
|
||||
// base.Setup();
|
||||
//
|
||||
// var xml = PublishedContentXml.BaseWebTestXml(1234);
|
||||
//
|
||||
// IEnumerable<ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
|
||||
// xml,
|
||||
// TestHelper.ShortStringHelper,
|
||||
// out var contentTypes,
|
||||
// out var dataTypes).ToList();
|
||||
//
|
||||
// InitializedCache(kits, contentTypes, dataTypes);
|
||||
// }
|
||||
//
|
||||
// private IFileService _fileService;
|
||||
//
|
||||
// protected override ServiceContext CreateServiceContext(IContentType[] contentTypes, IMediaType[] mediaTypes, IDataType[] dataTypes)
|
||||
// {
|
||||
// var serviceContext = base.CreateServiceContext(contentTypes, mediaTypes, dataTypes);
|
||||
//
|
||||
// var fileService = Mock.Get(serviceContext.FileService);
|
||||
// fileService.Setup(x => x.GetTemplate(It.IsAny<string>()))
|
||||
// .Returns((string alias) => new Template(ShortStringHelper, alias, alias));
|
||||
//
|
||||
// _fileService = fileService.Object;
|
||||
//
|
||||
// return serviceContext;
|
||||
// }
|
||||
//
|
||||
// [TestCase("/blah")]
|
||||
// [TestCase("/home/Sub1/blah")]
|
||||
// [TestCase("/Home/Sub1/Blah")] // different cases
|
||||
// public async Task Match_Document_By_Url_With_Template(string urlAsString)
|
||||
// {
|
||||
// GlobalSettings.HideTopLevelNodeFromPath = false;
|
||||
//
|
||||
// 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 ContentFinderByUrlAndTemplate(
|
||||
// Mock.Of<ILogger<ContentFinderByUrlAndTemplate>>(),
|
||||
// _fileService,
|
||||
// ContentTypeService,
|
||||
// umbracoContextAccessor,
|
||||
// Mock.Of<IOptionsMonitor<WebRoutingSettings>>(x => x.CurrentValue == webRoutingSettings));
|
||||
//
|
||||
// var result = await lookup.TryFindContent(frequest);
|
||||
//
|
||||
// var request = frequest.Build();
|
||||
//
|
||||
// Assert.IsTrue(result);
|
||||
// Assert.IsNotNull(frequest.PublishedContent);
|
||||
// var templateAlias = request.GetTemplateAlias();
|
||||
// Assert.IsNotNull(templateAlias);
|
||||
// Assert.AreEqual("blah".ToUpperInvariant(), templateAlias.ToUpperInvariant());
|
||||
// }
|
||||
// }
|
||||
@@ -1,165 +0,0 @@
|
||||
// using System.Collections.Generic;
|
||||
// using System.Diagnostics;
|
||||
// using System.Linq;
|
||||
// using System.Threading.Tasks;
|
||||
// using Microsoft.Extensions.Logging;
|
||||
// using Moq;
|
||||
// using NUnit.Framework;
|
||||
// using Umbraco.Cms.Core.Routing;
|
||||
// using Umbraco.Cms.Infrastructure.PublishedCache;
|
||||
// using Umbraco.Cms.Tests.Common.Published;
|
||||
// using Umbraco.Cms.Tests.UnitTests.TestHelpers;
|
||||
// using Umbraco.Extensions;
|
||||
//
|
||||
// namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing;
|
||||
//
|
||||
// FIXME: Reintroduce if relevant
|
||||
// [TestFixture]
|
||||
// public class ContentFinderByUrlTests : PublishedSnapshotServiceTestBase
|
||||
// {
|
||||
// private async Task<(ContentFinderByUrl finder, IPublishedRequestBuilder frequest)> GetContentFinder(
|
||||
// string urlString)
|
||||
// {
|
||||
// var xml = PublishedContentXml.BaseWebTestXml(1234);
|
||||
//
|
||||
// IEnumerable<ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
|
||||
// xml,
|
||||
// TestHelper.ShortStringHelper,
|
||||
// out var contentTypes,
|
||||
// out var dataTypes).ToList();
|
||||
//
|
||||
// InitializedCache(kits, contentTypes, dataTypes);
|
||||
//
|
||||
// var umbracoContextAccessor = GetUmbracoContextAccessor(urlString);
|
||||
// var umbracoContext = umbracoContextAccessor.GetRequiredUmbracoContext();
|
||||
// var publishedRouter = CreatePublishedRouter(umbracoContextAccessor);
|
||||
// var frequest = await publishedRouter.CreateRequestAsync(umbracoContext.CleanedUmbracoUrl);
|
||||
// var lookup = new ContentFinderByUrl(Mock.Of<ILogger<ContentFinderByUrl>>(), umbracoContextAccessor);
|
||||
// return (lookup, frequest);
|
||||
// }
|
||||
//
|
||||
// [TestCase("/", 1046)]
|
||||
// [TestCase("/Sub1", 1173)]
|
||||
// [TestCase("/sub1", 1173)]
|
||||
// [TestCase("/home/sub1", -1)] // should fail
|
||||
//
|
||||
// // these two are special. getNiceUrl(1046) returns "/" but getNiceUrl(1172) cannot also return "/" so
|
||||
// // we've made it return "/test-page" => we have to support that URL back in the lookup...
|
||||
// [TestCase("/home", 1046)]
|
||||
// [TestCase("/test-page", 1172)]
|
||||
// public async Task Match_Document_By_Url_Hide_Top_Level(string urlString, int expectedId)
|
||||
// {
|
||||
// GlobalSettings.HideTopLevelNodeFromPath = true;
|
||||
//
|
||||
// var (finder, frequest) = await GetContentFinder(urlString);
|
||||
//
|
||||
// Assert.IsTrue(GlobalSettings.HideTopLevelNodeFromPath);
|
||||
//
|
||||
// // TODO: debugging - going further down, the routes cache is NOT empty?!
|
||||
// if (urlString == "/home/sub1")
|
||||
// {
|
||||
// Debugger.Break();
|
||||
// }
|
||||
//
|
||||
// var result = await finder.TryFindContent(frequest);
|
||||
//
|
||||
// if (expectedId > 0)
|
||||
// {
|
||||
// Assert.IsTrue(result);
|
||||
// Assert.AreEqual(expectedId, frequest.PublishedContent.Id);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Assert.IsFalse(result);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestCase("/", 1046)]
|
||||
// [TestCase("/home", 1046)]
|
||||
// [TestCase("/home/Sub1", 1173)]
|
||||
// [TestCase("/Home/Sub1", 1173)] // different cases
|
||||
// public async Task Match_Document_By_Url(string urlString, int expectedId)
|
||||
// {
|
||||
// GlobalSettings.HideTopLevelNodeFromPath = false;
|
||||
//
|
||||
// var (finder, frequest) = await GetContentFinder(urlString);
|
||||
//
|
||||
// Assert.IsFalse(GlobalSettings.HideTopLevelNodeFromPath);
|
||||
//
|
||||
// var result = await finder.TryFindContent(frequest);
|
||||
//
|
||||
// Assert.IsTrue(result);
|
||||
// Assert.AreEqual(expectedId, frequest.PublishedContent.Id);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// This test handles requests with special characters in the URL.
|
||||
// /// </summary>
|
||||
// /// <param name="urlString"></param>
|
||||
// /// <param name="expectedId"></param>
|
||||
// [TestCase("/", 1046)]
|
||||
// [TestCase("/home/sub1/custom-sub-3-with-accént-character", 1179)]
|
||||
// [TestCase("/home/sub1/custom-sub-4-with-æøå", 1180)]
|
||||
// public async Task Match_Document_By_Url_With_Special_Characters(string urlString, int expectedId)
|
||||
// {
|
||||
// GlobalSettings.HideTopLevelNodeFromPath = false;
|
||||
//
|
||||
// var (finder, frequest) = await GetContentFinder(urlString);
|
||||
//
|
||||
// var result = await finder.TryFindContent(frequest);
|
||||
//
|
||||
// Assert.IsTrue(result);
|
||||
// Assert.AreEqual(expectedId, frequest.PublishedContent.Id);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// This test handles requests with a hostname associated.
|
||||
// /// The logic for handling this goes through the DomainHelper and is a bit different
|
||||
// /// from what happens in a normal request - so it has a separate test with a mocked
|
||||
// /// hostname added.
|
||||
// /// </summary>
|
||||
// /// <param name="urlString"></param>
|
||||
// /// <param name="expectedId"></param>
|
||||
// [TestCase("/", 1046)]
|
||||
// [TestCase("/home/sub1/custom-sub-3-with-accént-character", 1179)]
|
||||
// [TestCase("/home/sub1/custom-sub-4-with-æøå", 1180)]
|
||||
// public async Task Match_Document_By_Url_With_Special_Characters_Using_Hostname(string urlString, int expectedId)
|
||||
// {
|
||||
// GlobalSettings.HideTopLevelNodeFromPath = false;
|
||||
//
|
||||
// var (finder, frequest) = await GetContentFinder(urlString);
|
||||
//
|
||||
// frequest.SetDomain(new DomainAndUri(new Domain(1, "mysite", -1, "en-US", false, 0), new Uri("http://mysite/")));
|
||||
//
|
||||
// var result = await finder.TryFindContent(frequest);
|
||||
//
|
||||
// Assert.IsTrue(result);
|
||||
// Assert.AreEqual(expectedId, frequest.PublishedContent.Id);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// This test handles requests with a hostname with special characters associated.
|
||||
// /// The logic for handling this goes through the DomainHelper and is a bit different
|
||||
// /// from what happens in a normal request - so it has a separate test with a mocked
|
||||
// /// hostname added.
|
||||
// /// </summary>
|
||||
// /// <param name="urlString"></param>
|
||||
// /// <param name="expectedId"></param>
|
||||
// [TestCase("/æøå/", 1046)]
|
||||
// [TestCase("/æøå/home/sub1", 1173)]
|
||||
// [TestCase("/æøå/home/sub1/custom-sub-3-with-accént-character", 1179)]
|
||||
// [TestCase("/æøå/home/sub1/custom-sub-4-with-æøå", 1180)]
|
||||
// public async Task Match_Document_By_Url_With_Special_Characters_In_Hostname(string urlString, int expectedId)
|
||||
// {
|
||||
// GlobalSettings.HideTopLevelNodeFromPath = false;
|
||||
//
|
||||
// var (finder, frequest) = await GetContentFinder(urlString);
|
||||
//
|
||||
// frequest.SetDomain(new DomainAndUri(new Domain(1, "mysite/æøå", -1, "en-US", false, 0), new Uri("http://mysite/æøå")));
|
||||
//
|
||||
// var result = await finder.TryFindContent(frequest);
|
||||
//
|
||||
// Assert.IsTrue(result);
|
||||
// Assert.AreEqual(expectedId, frequest.PublishedContent.Id);
|
||||
// }
|
||||
// }
|
||||
@@ -1,257 +0,0 @@
|
||||
// using System.Threading;
|
||||
// using System.Threading.Tasks;
|
||||
// using Microsoft.Extensions.Logging;
|
||||
// using Moq;
|
||||
// using NUnit.Framework;
|
||||
// using Umbraco.Cms.Core.Models;
|
||||
// using Umbraco.Cms.Core.Routing;
|
||||
// using Umbraco.Extensions;
|
||||
//
|
||||
// namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing;
|
||||
//
|
||||
// FIXME: Reintroduce if relevant
|
||||
// [TestFixture]
|
||||
// public class ContentFinderByUrlWithDomainsTests : UrlRoutingTestBase
|
||||
// {
|
||||
// private void SetDomains3()
|
||||
// {
|
||||
// var domainService = Mock.Get(DomainService);
|
||||
//
|
||||
// domainService.Setup(service => service.GetAll(It.IsAny<bool>()))
|
||||
// .Returns((bool incWildcards) => new[]
|
||||
// {
|
||||
// new UmbracoDomain("domain1.com/")
|
||||
// {
|
||||
// Id = 1, LanguageId = LangDeId, RootContentId = 1001,
|
||||
// LanguageIsoCode = "de-DE",
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// private void SetDomains4()
|
||||
// {
|
||||
// var domainService = Mock.Get(DomainService);
|
||||
//
|
||||
// domainService.Setup(service => service.GetAll(It.IsAny<bool>()))
|
||||
// .Returns((bool incWildcards) => new[]
|
||||
// {
|
||||
// new UmbracoDomain("domain1.com/")
|
||||
// {
|
||||
// Id = 1, LanguageId = LangEngId, RootContentId = 1001, LanguageIsoCode = "en-US",
|
||||
// },
|
||||
// new UmbracoDomain("domain1.com/en")
|
||||
// {
|
||||
// Id = 2, LanguageId = LangEngId, RootContentId = 10011, LanguageIsoCode = "en-US",
|
||||
// },
|
||||
// new UmbracoDomain("domain1.com/fr")
|
||||
// {
|
||||
// Id = 3, LanguageId = LangFrId, RootContentId = 10012, LanguageIsoCode = "fr-FR",
|
||||
// },
|
||||
// new UmbracoDomain("http://domain3.com/")
|
||||
// {
|
||||
// Id = 4, LanguageId = LangEngId, RootContentId = 1003, LanguageIsoCode = "en-US",
|
||||
// },
|
||||
// new UmbracoDomain("http://domain3.com/en")
|
||||
// {
|
||||
// Id = 5, LanguageId = LangEngId, RootContentId = 10031, LanguageIsoCode = "en-US",
|
||||
// },
|
||||
// new UmbracoDomain("http://domain3.com/fr")
|
||||
// {
|
||||
// Id = 6, LanguageId = LangFrId, RootContentId = 10032, LanguageIsoCode = "fr-FR",
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// protected override string GetXmlContent(int templateId)
|
||||
// => @"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
// <!DOCTYPE root[
|
||||
// <!ELEMENT Doc ANY>
|
||||
// <!ATTLIST Doc id ID #REQUIRED>
|
||||
// ]>
|
||||
// <root id=""-1"">
|
||||
// <Doc id=""1001"" parentID=""-1"" level=""1"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""0"" createDate=""2012-06-12T14:13:17"" updateDate=""2012-07-20T18:50:43"" nodeName=""Home"" urlName=""1001"" writerName=""admin"" creatorName=""admin"" path=""-1,1001"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// <Doc id=""10011"" parentID=""1001"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""0"" createDate=""2012-07-20T18:06:45"" updateDate=""2012-07-20T19:07:31"" nodeName=""Sub1"" urlName=""1001-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1001,10011"" isDoc="""">
|
||||
// <content><![CDATA[<div>This is some content</div>]]></content>
|
||||
// <Doc id=""100111"" parentID=""10011"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""0"" createDate=""2012-07-20T18:07:54"" updateDate=""2012-07-20T19:10:27"" nodeName=""Sub2"" urlName=""1001-1-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1001,10011,100111"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// </Doc>
|
||||
// <Doc id=""100112"" parentID=""10011"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""1"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""1001-1-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1001,10011,100112"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// <Doc id=""1001121"" parentID=""100112"" level=""4"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""1"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""1001-1-2-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1001,10011,100112,1001121"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// </Doc>
|
||||
// <Doc id=""1001122"" parentID=""100112"" level=""4"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""1"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""1001-1-2-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1001,10011,100112,1001122"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// </Doc>
|
||||
// </Doc>
|
||||
// </Doc>
|
||||
// <Doc id=""10012"" parentID=""1001"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""1"" createDate=""2012-07-20T18:08:01"" updateDate=""2012-07-20T18:49:32"" nodeName=""Sub 2"" urlName=""1001-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1001,10012"" isDoc="""">
|
||||
// <content><![CDATA[<div>This is some content</div>]]></content>
|
||||
// <Doc id=""100121"" parentID=""10012"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""0"" createDate=""2012-07-20T18:07:54"" updateDate=""2012-07-20T19:10:27"" nodeName=""Sub2"" urlName=""1001-2-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1001,10012,100121"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// </Doc>
|
||||
// <Doc id=""100122"" parentID=""10012"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""1"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""1001-2-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1001,10012,100122"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// <Doc id=""1001221"" parentID=""100122"" level=""4"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""1"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""1001-2-2-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1001,10012,100122,1001221"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// </Doc>
|
||||
// <Doc id=""1001222"" parentID=""100122"" level=""4"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""1"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""1001-2-2-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1001,10012,100122,1001222"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// </Doc>
|
||||
// </Doc>
|
||||
// </Doc>
|
||||
// <Doc id=""10013"" parentID=""1001"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""2"" createDate=""2012-07-20T18:08:01"" updateDate=""2012-07-20T18:49:32"" nodeName=""Sub 2"" urlName=""1001-3"" writerName=""admin"" creatorName=""admin"" path=""-1,1001,10013"" isDoc="""">
|
||||
// </Doc>
|
||||
// </Doc>
|
||||
// <Doc id=""1002"" parentID=""-1"" level=""1"" writerID=""0"" creatorID=""0"" nodeType=""1234"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""2"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-18T14:23:35"" nodeName=""Test"" urlName=""1002"" writerName=""admin"" creatorName=""admin"" path=""-1,1002"" isDoc="""">
|
||||
// </Doc>
|
||||
// <Doc id=""1003"" parentID=""-1"" level=""1"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""0"" createDate=""2012-06-12T14:13:17"" updateDate=""2012-07-20T18:50:43"" nodeName=""Home"" urlName=""1003"" writerName=""admin"" creatorName=""admin"" path=""-1,1003"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// <Doc id=""10031"" parentID=""1003"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""0"" createDate=""2012-07-20T18:06:45"" updateDate=""2012-07-20T19:07:31"" nodeName=""Sub1"" urlName=""1003-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1003,10031"" isDoc="""">
|
||||
// <content><![CDATA[<div>This is some content</div>]]></content>
|
||||
// <Doc id=""100311"" parentID=""10031"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""0"" createDate=""2012-07-20T18:07:54"" updateDate=""2012-07-20T19:10:27"" nodeName=""Sub2"" urlName=""1003-1-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1003,10031,100311"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// </Doc>
|
||||
// <Doc id=""100312"" parentID=""10031"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""1"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""1003-1-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1003,10031,100312"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// <Doc id=""1003121"" parentID=""100312"" level=""4"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""1"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""1003-1-2-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1003,10031,100312,1003121"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// </Doc>
|
||||
// <Doc id=""1003122"" parentID=""100312"" level=""4"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""1"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""1003-1-2-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1003,10031,100312,1003122"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// </Doc>
|
||||
// </Doc>
|
||||
// </Doc>
|
||||
// <Doc id=""10032"" parentID=""1003"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""1"" createDate=""2012-07-20T18:08:01"" updateDate=""2012-07-20T18:49:32"" nodeName=""Sub 2"" urlName=""1003-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1003,10032"" isDoc="""">
|
||||
// <content><![CDATA[<div>This is some content</div>]]></content>
|
||||
// <Doc id=""100321"" parentID=""10032"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""0"" createDate=""2012-07-20T18:07:54"" updateDate=""2012-07-20T19:10:27"" nodeName=""Sub2"" urlName=""1003-2-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1003,10032,100321"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// </Doc>
|
||||
// <Doc id=""100322"" parentID=""10032"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""1"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""1003-2-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1003,10032,100322"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// <Doc id=""1003221"" parentID=""100322"" level=""4"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""0"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""1003-2-2-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1003,10032,100322,1003221"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// </Doc>
|
||||
// <Doc id=""1003222"" parentID=""100322"" level=""4"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""1"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""1003-2-2-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1003,10032,100322,1003222"" isDoc="""">
|
||||
// <content><![CDATA[]]></content>
|
||||
// </Doc>
|
||||
// </Doc>
|
||||
// </Doc>
|
||||
// <Doc id=""10033"" parentID=""1003"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" +
|
||||
// templateId +
|
||||
// @""" sortOrder=""2"" createDate=""2012-07-20T18:08:01"" updateDate=""2012-07-20T18:49:32"" nodeName=""Sub 2"" urlName=""1003-3"" writerName=""admin"" creatorName=""admin"" path=""-1,1003,10033"" isDoc="""">
|
||||
// </Doc>
|
||||
// </Doc>
|
||||
// </root>";
|
||||
//
|
||||
// [TestCase("http://domain1.com/", 1001)]
|
||||
// [TestCase("http://domain1.com/1001-1", 10011)]
|
||||
// [TestCase("http://domain1.com/1001-2/1001-2-1", 100121)]
|
||||
// public async Task Lookup_SingleDomain(string url, int expectedId)
|
||||
// {
|
||||
// SetDomains3();
|
||||
//
|
||||
// GlobalSettings.HideTopLevelNodeFromPath = true;
|
||||
//
|
||||
// var umbracoContextAccessor = GetUmbracoContextAccessor(url);
|
||||
// var publishedRouter = CreatePublishedRouter(umbracoContextAccessor);
|
||||
// var umbracoContext = umbracoContextAccessor.GetRequiredUmbracoContext();
|
||||
// var frequest = await publishedRouter.CreateRequestAsync(umbracoContext.CleanedUmbracoUrl);
|
||||
//
|
||||
// // must lookup domain else lookup by URL fails
|
||||
// publishedRouter.FindAndSetDomain(frequest);
|
||||
//
|
||||
// var lookup = new ContentFinderByUrl(Mock.Of<ILogger<ContentFinderByUrl>>(), umbracoContextAccessor);
|
||||
// var result = await lookup.TryFindContent(frequest);
|
||||
// Assert.IsTrue(result);
|
||||
// Assert.AreEqual(expectedId, frequest.PublishedContent.Id);
|
||||
// }
|
||||
//
|
||||
// [TestCase("http://domain1.com/", 1001, "en-US")]
|
||||
// [TestCase("http://domain1.com/en", 10011, "en-US")]
|
||||
// [TestCase("http://domain1.com/en/1001-1-1", 100111, "en-US")]
|
||||
// [TestCase("http://domain1.com/fr", 10012, "fr-FR")]
|
||||
// [TestCase("http://domain1.com/fr/1001-2-1", 100121, "fr-FR")]
|
||||
// [TestCase("http://domain1.com/1001-3", 10013, "en-US")]
|
||||
// [TestCase("http://domain2.com/1002", 1002, "")]
|
||||
// [TestCase("http://domain3.com/", 1003, "en-US")]
|
||||
// [TestCase("http://domain3.com/en", 10031, "en-US")]
|
||||
// [TestCase("http://domain3.com/en/1003-1-1", 100311, "en-US")]
|
||||
// [TestCase("http://domain3.com/fr", 10032, "fr-FR")]
|
||||
// [TestCase("http://domain3.com/fr/1003-2-1", 100321, "fr-FR")]
|
||||
// [TestCase("http://domain3.com/1003-3", 10033, "en-US")]
|
||||
// [TestCase("https://domain1.com/", 1001, "en-US")]
|
||||
// [TestCase("https://domain3.com/", 1001, "")] // because domain3 is explicitely set on http
|
||||
// public async Task Lookup_NestedDomains(string url, int expectedId, string expectedCulture)
|
||||
// {
|
||||
// SetDomains4();
|
||||
//
|
||||
// // defaults depend on test environment
|
||||
// expectedCulture ??= Thread.CurrentThread.CurrentUICulture.Name;
|
||||
//
|
||||
// GlobalSettings.HideTopLevelNodeFromPath = true;
|
||||
//
|
||||
// var umbracoContextAccessor = GetUmbracoContextAccessor(url);
|
||||
// var publishedRouter = CreatePublishedRouter(umbracoContextAccessor);
|
||||
// var umbracoContext = umbracoContextAccessor.GetRequiredUmbracoContext();
|
||||
// var frequest = await publishedRouter.CreateRequestAsync(umbracoContext.CleanedUmbracoUrl);
|
||||
//
|
||||
// // must lookup domain else lookup by URL fails
|
||||
// publishedRouter.FindAndSetDomain(frequest);
|
||||
// Assert.AreEqual(expectedCulture, frequest.Culture);
|
||||
//
|
||||
// var lookup = new ContentFinderByUrl(Mock.Of<ILogger<ContentFinderByUrl>>(), umbracoContextAccessor);
|
||||
// var result = await lookup.TryFindContent(frequest);
|
||||
// Assert.IsTrue(result);
|
||||
// Assert.AreEqual(expectedId, frequest.PublishedContent.Id);
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user