* starts cleaning up old test project, removing ones we'll never convert, moves new test to where it should be. * Makes ContentNodeKit immutable properties, moves first nucache tests over * Gets the Nucache unit tests working and refactors a bit to use builder pattern for models. * Migrates first xml based cache test to use nucache. * Migrates a bunch more * Migrates remaining tests for PublishedContentTests * Moves PublishedRouterTests * Moves PublishedContentExtensionTests * Moves more tests. * committing wip * committing wip * Gets PublishedContentLanguageVariantTests converted and working. * Fixes DataTable ext method and moves PublishedContentDataTableTests * Moves PublishedMediaTests * wip - moving EntityXmlSerializerTests * Moves more tests * moves more tests * moves more tests * Move another test * Moves more tests * Fix test * move another test * Moves more tests * Moves more tests * Moves more tests * wip before merge * More tests * More tests * More tests * More tests * More tests * More tests * Cleanup and moving classes. * Remove unused code * Fixed failing tests, due to new null checks, that did not exist in v8 * Avoid breaking changes * Unbreak more things, even that it the old solution was crazy.. * Fixed bug where ordering of stream readings was changed.. * cleanup Co-authored-by: Bjarke Berg <mail@bergmania.dk>
64 lines
2.4 KiB
C#
64 lines
2.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Web;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
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 ContentFinderByPageIdQueryTests : 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("/?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 = lookup.TryFindContent(frequest);
|
|
|
|
Assert.IsTrue(result);
|
|
Assert.AreEqual(frequest.PublishedContent.Id, nodeMatch);
|
|
}
|
|
}
|
|
}
|