* 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>
86 lines
2.6 KiB
C#
86 lines
2.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using NUnit.Framework;
|
|
using Umbraco.Cms.Core.Models;
|
|
using Umbraco.Cms.Core.PublishedCache;
|
|
using Umbraco.Cms.Infrastructure.PublishedCache;
|
|
using Umbraco.Cms.Tests.Common.Published;
|
|
using Umbraco.Cms.Tests.UnitTests.TestHelpers;
|
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.PublishedCache
|
|
{
|
|
[TestFixture]
|
|
public class PublishContentCacheTests : PublishedSnapshotServiceTestBase
|
|
{
|
|
private IPublishedContentCache _cache;
|
|
|
|
[SetUp]
|
|
public override void Setup()
|
|
{
|
|
base.Setup();
|
|
|
|
string xml = PublishedContentXml.PublishContentCacheTestsXml();
|
|
|
|
IEnumerable<ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
|
|
xml,
|
|
TestHelper.ShortStringHelper,
|
|
out ContentType[] contentTypes,
|
|
out DataType[] dataTypes).ToList();
|
|
|
|
// configure the Home content type to be composed of another for tests.
|
|
var compositionType = new ContentType(TestHelper.ShortStringHelper, -1)
|
|
{
|
|
Alias = "MyCompositionAlias"
|
|
};
|
|
contentTypes.First(x => x.Alias == "Home").AddContentType(compositionType);
|
|
|
|
InitializedCache(kits, contentTypes, dataTypes: dataTypes);
|
|
|
|
_cache = GetPublishedSnapshot().Content;
|
|
}
|
|
|
|
[Test]
|
|
public void Has_Content()
|
|
{
|
|
Assert.IsTrue(_cache.HasContent());
|
|
}
|
|
|
|
|
|
[Test]
|
|
public void Get_Root_Docs()
|
|
{
|
|
var result = _cache.GetAtRoot();
|
|
Assert.AreEqual(2, result.Count());
|
|
Assert.AreEqual(1046, result.ElementAt(0).Id);
|
|
Assert.AreEqual(1172, result.ElementAt(1).Id);
|
|
}
|
|
|
|
|
|
[TestCase("/", 1046)]
|
|
[TestCase("/home", 1046)]
|
|
[TestCase("/Home", 1046)] //test different cases
|
|
[TestCase("/home/sub1", 1173)]
|
|
[TestCase("/Home/sub1", 1173)]
|
|
[TestCase("/home/Sub1", 1173)] //test different cases
|
|
[TestCase("/home/Sub'Apostrophe", 1177)]
|
|
public void Get_Node_By_Route(string route, int nodeId)
|
|
{
|
|
var result = _cache.GetByRoute(route, false);
|
|
Assert.IsNotNull(result);
|
|
Assert.AreEqual(nodeId, result.Id);
|
|
}
|
|
|
|
|
|
|
|
[TestCase("/", 1046)]
|
|
[TestCase("/sub1", 1173)]
|
|
[TestCase("/Sub1", 1173)]
|
|
public void Get_Node_By_Route_Hiding_Top_Level_Nodes(string route, int nodeId)
|
|
{
|
|
var result = _cache.GetByRoute(route, true);
|
|
Assert.IsNotNull(result);
|
|
Assert.AreEqual(nodeId, result.Id);
|
|
}
|
|
}
|
|
}
|