Files
Umbraco-CMS/tests/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/PublishedCache/PublishedContentExtensionTests.cs
Nikolaj Geisle 7aeb400fce V10: fix build warnings in test projects (#12509)
* Run code cleanup

* Dotnet format benchmarks project

* Fix up Test.Common

* Run dotnet format + manual cleanup

* Run code cleanup for unit tests

* Run dotnet format

* Fix up errors

* Manual cleanup of Unit test project

* Update tests/Umbraco.Tests.Benchmarks/HexStringBenchmarks.cs

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Update tests/Umbraco.Tests.Integration/Testing/TestDbMeta.cs

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Update tests/Umbraco.Tests.Benchmarks/TypeFinderBenchmarks.cs

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Update tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Update tests/Umbraco.Tests.Integration/Umbraco.Core/Events/EventAggregatorTests.cs

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Fix according to review

* Fix after merge

* Fix errors

Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk>
Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>
Co-authored-by: Zeegaan <nge@umbraco.dk>
2022-06-21 08:09:38 +02:00

77 lines
2.5 KiB
C#

using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Umbraco.Cms.Core.Models;
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.Infrastructure.PublishedCache;
[TestFixture]
public class PublishedContentExtensionTests : PublishedSnapshotServiceTestBase
{
[SetUp]
public override void Setup()
{
base.Setup();
IEnumerable<ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
XmlContent,
TestHelper.ShortStringHelper,
out var contentTypes,
out var dataTypes).ToList();
// configure inheritance for content types
var baseType = new ContentType(TestHelper.ShortStringHelper, -1) { Alias = "Base" };
contentTypes[0].AddContentType(baseType);
InitializedCache(kits, contentTypes, dataTypes);
}
private const string XmlContent = @"<?xml version=""1.0"" encoding=""utf-8""?>
<!DOCTYPE root[
<!ELEMENT inherited ANY>
<!ATTLIST inherited id ID #REQUIRED>
]>
<root id=""-1"">
<inherited id=""1100"" parentID=""-1"" level=""1"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""1"" sortOrder=""1"" createDate=""2012-06-12T14:13:17"" updateDate=""2012-07-20T18:50:43"" nodeName=""Home"" urlName=""home"" writerName=""admin"" creatorName=""admin"" path=""-1,1046"" isDoc=""""/>
</root>";
[Test]
public void IsDocumentType_NonRecursive_ActualType_ReturnsTrue()
{
var publishedContent = GetContent(1100);
Assert.That(publishedContent.IsDocumentType("Inherited", false));
}
[Test]
public void IsDocumentType_NonRecursive_BaseType_ReturnsFalse()
{
var publishedContent = GetContent(1100);
Assert.That(publishedContent.IsDocumentType("Base", false), Is.False);
}
[Test]
public void IsDocumentType_Recursive_ActualType_ReturnsTrue()
{
var publishedContent = GetContent(1100);
Assert.That(publishedContent.IsDocumentType("Inherited", true));
}
[Test]
public void IsDocumentType_Recursive_BaseType_ReturnsTrue()
{
var publishedContent = GetContent(1100);
Assert.That(publishedContent.IsDocumentType("Base", true));
}
[Test]
public void IsDocumentType_Recursive_InvalidBaseType_ReturnsFalse()
{
var publishedContent = GetContent(1100);
Assert.That(publishedContent.IsDocumentType("invalidbase", true), Is.False);
}
}