Add breaking NuCache test

This commit is contained in:
Stephan
2019-09-16 17:21:12 +02:00
parent be0d38f2af
commit c1d3bfaa5d

View File

@@ -1,7 +1,9 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using Moq;
using NUnit.Framework;
using Umbraco.Core;
@@ -25,6 +27,7 @@ using Umbraco.Web.Cache;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.PublishedCache.NuCache;
using Umbraco.Web.PublishedCache.NuCache.DataSource;
using Umbraco.Web.PublishedCache.NuCache.Snap;
namespace Umbraco.Tests.PublishedContent
{
@@ -163,7 +166,7 @@ namespace Umbraco.Tests.PublishedContent
//1x variant (root)
yield return CreateVariantKit(1, -1, 1, paths);
//1x invariant under root
yield return CreateInvariantKit(4, 1, 1, paths);
@@ -952,6 +955,43 @@ namespace Umbraco.Tests.PublishedContent
AssertDocuments(documents, "N1-en-US", "N2-en-US", "N3-en-US");
}
[Test]
public void Issue6353()
{
IEnumerable<ContentNodeKit> GetKits()
{
var paths = new Dictionary<int, string> { { -1, "-1" } };
yield return CreateInvariantKit(1, -1, 1, paths);
yield return CreateInvariantKit(2, 1, 1, paths);
}
Init(GetKits());
var snapshotService = (PublishedSnapshotService) _snapshotService;
var contentStoreField = typeof(PublishedSnapshotService).GetField("_contentStore", BindingFlags.Instance | BindingFlags.NonPublic);
var contentStore = (ContentStore) contentStoreField.GetValue(snapshotService);
var contentNodesField = typeof(ContentStore).GetField("_contentNodes", BindingFlags.Instance | BindingFlags.NonPublic);
var contentNodes = (ConcurrentDictionary<int, LinkedNode<ContentNode>>) contentNodesField.GetValue(contentStore);
var parentNode = contentNodes[1].Value;
Assert.AreEqual(-1, parentNode.PreviousSiblingContentId);
Assert.AreEqual(-1, parentNode.NextSiblingContentId);
Assert.AreEqual(2, parentNode.FirstChildContentId);
Assert.AreEqual(2, parentNode.LastChildContentId);
_snapshotService.Notify(new[]
{
new ContentCacheRefresher.JsonPayload(2, TreeChangeTypes.Remove)
}, out _, out _);
parentNode = contentNodes[1].Value;
Assert.AreEqual(-1, parentNode.PreviousSiblingContentId);
Assert.AreEqual(-1, parentNode.NextSiblingContentId);
Assert.AreEqual(-1, parentNode.FirstChildContentId);
Assert.AreEqual(-1, parentNode.LastChildContentId);
}
private void AssertDocuments(IPublishedContent[] documents, params string[] names)
{
Assert.AreEqual(names.Length, documents.Length);