Files
Umbraco-CMS/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Routing/ContentFinderByIdTests.cs
Bjarke Berg 78dc2d5721 Merge remote-tracking branch 'origin/v9/dev' into v10/dev
# Conflicts:
#	build/azure-pipelines.yml
#	src/Umbraco.Core/Routing/DefaultUrlProvider.cs
#	src/Umbraco.Core/Routing/UrlProviderExtensions.cs
#	src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs
#	src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentRepository.cs
#	src/Umbraco.Infrastructure/Services/Implement/ContentService.cs
#	src/Umbraco.PublishedCache.NuCache/DataSource/BTree.ContentDataSerializer.cs
#	src/Umbraco.PublishedCache.NuCache/Persistence/NuCacheContentRepository.cs
#	src/Umbraco.Web.UI.Client/package-lock.json
#	tests/Umbraco.Tests.AcceptanceTest/package-lock.json
#	tests/Umbraco.Tests.AcceptanceTest/package.json
#	tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceTests.cs
2021-11-22 19:43:20 +01:00

60 lines
2.1 KiB
C#

using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
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.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
{
[TestFixture]
public class ContentFinderByIdTests : PublishedSnapshotServiceTestBase
{
[SetUp]
public override void Setup()
{
base.Setup();
string xml = PublishedContentXml.BaseWebTestXml(1234);
IEnumerable<ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
xml,
TestHelper.ShortStringHelper,
out ContentType[] contentTypes,
out DataType[] dataTypes).ToList();
InitializedCache(kits, contentTypes, dataTypes: dataTypes);
}
[TestCase("/1046", 1046)]
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 = lookup.TryFindContent(frequest);
Assert.IsTrue(result);
Assert.AreEqual(frequest.PublishedContent.Id, nodeMatch);
}
}
}