* Removed obsoletes from IConfigManipulator. * Removed obsolete models builder extensions. * Removed the obsolete ContentDashboardSettings. * Removed the obsolete InstallMissingDatabase setting on GlobalSettings. * Removed obsolete NuCache settings. * Removed obsolete RuntimeMinificationSettings. * Removed obsolete health check constant. * Removed obsolete icon constant. * Removed obsolete telemetry constant. * Removed obsolete property and constructor on UmbracoBuilder. * Removed obsolete constructor on AuditNotificationsHandler. * Removed obsolete constructor on HTTP header health checks. * Removed obsolete constructor on MediaFileManager. * Removed obsolete GetDefaultFileContent on ViewHelper. * Remove obsoleted methods on embed providers. * Fix tests. * Removed obsolete constructors on BlockEditorDataConverter. * Removed obsolete SeedCacheDuration property on CacheSettings. * Removed obsolete PublishCulture on ContentRepositoryExtensions. * Removed obsolete MonitorLock. * Removed obsolete synchronous HasSavedValues from IDataTypeUsageService and IDataTypeUsageRepository. * Removed obsolete HasSavedPropertyValues from IPropertyTypeUsageService and IPropertyTypeUsageRepository. * Removed obsolete methods in ITrackedReferencesService and ITrackedReferencesRepository. * Removed obsolete DateValueEditor constructors. * Removed obsolete GetAutomaticRelationTypesAliases. * Removed obsolete constructor on TextOnlyValueEditor. * Removed obsolete constructors on RegexValidator and RequiredValidator. * Removed obsolete constructs on SliderValueConverter and TagsValueConverter. * Removed obsolete GetContentType methods from IPublishedCache. * Removed ContentFinderByIdPath. * Removed obsolete constructor on DefaultMediaUrlProvider. * Removed obsolete constructor on Domain. * Removed obsolete constructor on PublishedRequest. * Removed obsolete methods on CheckPermissions. * Removed obsolete GetUserId from IBackOfficeSecurity. * Removed obsolete methods on LegacyPasswordSecurity. * Removed obsolete constructors on AuditService. * Removed obsolete methods on IContentEditingService. * Remove obsolete constructors and methods on ContentService/IContentService. * Removed obsolete constructor in ContentTypeEditingService. * Removed obsolete constructor in MediaTypeEditingService. * Removed obsolete constructor in MemberTypeEditingService. * Removed obsolete constructor in ContentTypeService. * Removed obsolete constructors in ContentTypeServiceBase. * Removed obsolete constructors and methods in ContentVersionService. * Removed obsolete constructor in DataTypeUsageService. * Removed obsolete constructor in DomainService. * Removed obsolete constructor in FileService. * Removes obsolete AttemptMove from IContentService. * Removes obsolete SetPreventCleanup from IContentVersionService. * Removes obsolete GetReferences from IDataTypeService. * Removed obsolete SetConsentLevel from IMetricsConsentService. * Removed obsolete methods from IPackageDataInstallation. * Removed obsolete methods from IPackagingService. * Removed obsolete methods on ITwoFactorLoginService. Removed obsolete ITemporaryMediaService. * Removed obsolete constructor from MediaService, MemberTypeService and MediaTypeService. * More obsolete constructors. * Removed obsoleted overloads on IPropertyValidationService. * Fixed build for tests. * Removed obsolete constructor for PublicAccessService, UserService and RelationService. * Removed GetDefaultMemberType. * Removed obsolete user group functionality from IUserService. * Removed obsolete extension methods on IUserService. * Removed obsolete method from ITelemetryService. * Removed obsolete UdiParserServiceConnectors. * Removed obsolete method on ICookieManager. * Removed obsolete DynamicContext. * Removed obsolete XmlHelper. * Fixed failing integration tests. * Removed obsoletes in Umbraco.Cms.Api.Common * Removed obsoletes in Umbraco.Cms.Api.Delivery * Removed obsoletes in Umbraco.Cms.Api.Management * Removed obsoletes in Umbraco.Examine.Lucene * Removed obsoletes in Umbraco.Infrastructure * Fix failing delivery API contract integration test. * Made integration tests internal. * Removed obsoletes from web projects. * Fix build. * Removed Twitter OEmbed provider * Removed obsolete constructor on PublishedDataType. * Removed obsolete constructors on PublishedCacheBase. * Removed the obsolete PropertyEditorTagsExtensions. * Removed obsoletion properties on configuration response models (#18697) * Removed obsolete methods from server-side models. * Update client-side types and sdk. * Update client-side files. * Removed obsoletion of Utf8ToAsciiConverter.ToAsciiString overload. (#18694) * Removed obsolete method in UserService. (#18710) * Removed obsoleted group alias keys from being publicly available. (#18682) * Removed unneceessary ApiVersion attribute. * Clean-up obsoletions on MemberService (#18703) * Removed obsoleted method on MemberService, added future obsoletion to interface and updated all callers. * Removed obsoletion on member service method that's not obsolete on the interface.
328 lines
18 KiB
C#
328 lines
18 KiB
C#
using NUnit.Framework;
|
|
using Umbraco.Cms.Core;
|
|
using Umbraco.Cms.Core.Models;
|
|
using Umbraco.Cms.Core.Scoping;
|
|
using Umbraco.Cms.Tests.Common.Builders;
|
|
|
|
namespace Umbraco.Cms.Tests.Integration.Umbraco.Core.Services;
|
|
|
|
internal sealed partial class DocumentNavigationServiceTests : DocumentNavigationServiceTestsBase
|
|
{
|
|
[SetUp]
|
|
public async Task Setup()
|
|
{
|
|
// Root
|
|
// - Child 1
|
|
// - Grandchild 1
|
|
// - Grandchild 2
|
|
// - Child 2
|
|
// - Grandchild 3
|
|
// - Great-grandchild 1
|
|
// - Child 3
|
|
// - Grandchild 4
|
|
|
|
// Doc Type
|
|
ContentType = ContentTypeBuilder.CreateSimpleContentType("page", "Page");
|
|
ContentType.Key = new Guid("DD72B8A6-2CE3-47F0-887E-B695A1A5D086");
|
|
ContentType.AllowedAsRoot = true;
|
|
ContentType.AllowedContentTypes = new[] { new ContentTypeSort(ContentType.Key, 0, ContentType.Alias) };
|
|
await ContentTypeService.CreateAsync(ContentType, Constants.Security.SuperUserKey);
|
|
|
|
// Content
|
|
var rootModel = CreateContentCreateModel("Root", new Guid("E48DD82A-7059-418E-9B82-CDD5205796CF"));
|
|
var rootCreateAttempt = await ContentEditingService.CreateAsync(rootModel, Constants.Security.SuperUserKey);
|
|
Root = rootCreateAttempt.Result.Content!;
|
|
|
|
var child1Model = CreateContentCreateModel("Child 1", new Guid("C6173927-0C59-4778-825D-D7B9F45D8DDE"), parentKey: Root.Key);
|
|
var child1CreateAttempt = await ContentEditingService.CreateAsync(child1Model, Constants.Security.SuperUserKey);
|
|
Child1 = child1CreateAttempt.Result.Content!;
|
|
|
|
var grandchild1Model = CreateContentCreateModel("Grandchild 1", new Guid("E856AC03-C23E-4F63-9AA9-681B42A58573"), parentKey: Child1.Key);
|
|
var grandchild1CreateAttempt = await ContentEditingService.CreateAsync(grandchild1Model, Constants.Security.SuperUserKey);
|
|
Grandchild1 = grandchild1CreateAttempt.Result.Content!;
|
|
|
|
var grandchild2Model = CreateContentCreateModel("Grandchild 2", new Guid("A1B1B217-B02F-4307-862C-A5E22DB729EB"), parentKey: Child1.Key);
|
|
var grandchild2CreateAttempt = await ContentEditingService.CreateAsync(grandchild2Model, Constants.Security.SuperUserKey);
|
|
Grandchild2 = grandchild2CreateAttempt.Result.Content!;
|
|
|
|
var child2Model = CreateContentCreateModel("Child 2", new Guid("60E0E5C4-084E-4144-A560-7393BEAD2E96"), parentKey: Root.Key);
|
|
var child2CreateAttempt = await ContentEditingService.CreateAsync(child2Model, Constants.Security.SuperUserKey);
|
|
Child2 = child2CreateAttempt.Result.Content!;
|
|
|
|
var grandchild3Model = CreateContentCreateModel("Grandchild 3", new Guid("D63C1621-C74A-4106-8587-817DEE5FB732"), parentKey: Child2.Key);
|
|
var grandchild3CreateAttempt = await ContentEditingService.CreateAsync(grandchild3Model, Constants.Security.SuperUserKey);
|
|
Grandchild3 = grandchild3CreateAttempt.Result.Content!;
|
|
|
|
var greatGrandchild1Model = CreateContentCreateModel("Great-grandchild 1", new Guid("56E29EA9-E224-4210-A59F-7C2C5C0C5CC7"), parentKey: Grandchild3.Key);
|
|
var greatGrandchild1CreateAttempt = await ContentEditingService.CreateAsync(greatGrandchild1Model, Constants.Security.SuperUserKey);
|
|
GreatGrandchild1 = greatGrandchild1CreateAttempt.Result.Content!;
|
|
|
|
var child3Model = CreateContentCreateModel("Child 3", new Guid("B606E3FF-E070-4D46-8CB9-D31352029FDF"), parentKey: Root.Key);
|
|
var child3CreateAttempt = await ContentEditingService.CreateAsync(child3Model, Constants.Security.SuperUserKey);
|
|
Child3 = child3CreateAttempt.Result.Content!;
|
|
|
|
var grandchild4Model = CreateContentCreateModel("Grandchild 4", new Guid("F381906C-223C-4466-80F7-B63B4EE073F8"), parentKey: Child3.Key);
|
|
var grandchild4CreateAttempt = await ContentEditingService.CreateAsync(grandchild4Model, Constants.Security.SuperUserKey);
|
|
Grandchild4 = grandchild4CreateAttempt.Result.Content!;
|
|
}
|
|
|
|
[Test]
|
|
public async Task Structure_Does_Not_Update_When_Scope_Is_Not_Completed()
|
|
{
|
|
// Arrange
|
|
Guid notCreatedRootKey = new Guid("516927E5-8574-497B-B45B-E27EFAB47DE4");
|
|
|
|
// Create node at content root
|
|
var createModel = CreateContentCreateModel("Root 2", notCreatedRootKey);
|
|
|
|
using (ICoreScope scope = ScopeProvider.CreateCoreScope())
|
|
{
|
|
await ContentEditingService.CreateAsync(createModel, Constants.Security.SuperUserKey);
|
|
}
|
|
|
|
// Act
|
|
var nodeExists = DocumentNavigationQueryService.TryGetParentKey(notCreatedRootKey, out _);
|
|
|
|
// Assert
|
|
Assert.IsFalse(nodeExists);
|
|
}
|
|
|
|
[Test]
|
|
public async Task Can_Filter_Root_Items_By_Type()
|
|
{
|
|
// Arrange
|
|
DocumentNavigationQueryService.TryGetRootKeysOfType(ContentType.Alias, out IEnumerable<Guid> initialRootKeysOfType);
|
|
List<Guid> initialRootOfTypeList = initialRootKeysOfType.ToList();
|
|
|
|
// Doc Type
|
|
var anotherContentType = ContentTypeBuilder.CreateSimpleContentType("anotherPage", "Another page");
|
|
anotherContentType.Key = new Guid("58A2958E-B34F-4289-A225-E99EEC2456AB");
|
|
anotherContentType.AllowedContentTypes = new[] { new ContentTypeSort(anotherContentType.Key, 0, anotherContentType.Alias) };
|
|
anotherContentType.AllowedAsRoot = true;
|
|
await ContentTypeService.CreateAsync(anotherContentType, Constants.Security.SuperUserKey);
|
|
|
|
// Update old doc type
|
|
ContentType.AllowedContentTypes = new[] { new ContentTypeSort(ContentType.Key, 0, ContentType.Alias), new ContentTypeSort(anotherContentType.Key, 1, anotherContentType.Alias) };
|
|
await ContentTypeService.UpdateAsync(ContentType, Constants.Security.SuperUserKey);
|
|
|
|
// Content
|
|
var root2Model = CreateContentCreateModel("Root 2", new Guid("11233548-2E87-4D3E-8FC4-4400F9DBEF56"), anotherContentType.Key); // Using new doc type
|
|
await ContentEditingService.CreateAsync(root2Model, Constants.Security.SuperUserKey);
|
|
var root3Model = CreateContentCreateModel("Root 3", new Guid("6E10F212-CE7F-47B5-A796-345861AEE613"), anotherContentType.Key); // Using new doc type
|
|
await ContentEditingService.CreateAsync(root3Model, Constants.Security.SuperUserKey);
|
|
|
|
// Act
|
|
DocumentNavigationQueryService.TryGetRootKeysOfType(anotherContentType.Alias, out IEnumerable<Guid> filteredRootKeysOfType);
|
|
List<Guid> filteredRootList = filteredRootKeysOfType.ToList();
|
|
|
|
DocumentNavigationQueryService.TryGetRootKeys(out IEnumerable<Guid> allRootKeys);
|
|
List<Guid> allRootList = allRootKeys.ToList();
|
|
|
|
// Assert
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.AreEqual(1, initialRootOfTypeList.Count); // Verify that loaded doc types can be used to filter
|
|
Assert.AreEqual(2, filteredRootList.Count); // Verify that new doc type can be used to filter
|
|
Assert.AreEqual(3, allRootList.Count);
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public async Task Can_Filter_Children_By_Type()
|
|
{
|
|
// Arrange
|
|
Guid parentKey = Root.Key;
|
|
DocumentNavigationQueryService.TryGetChildrenKeysOfType(parentKey, ContentType.Alias, out IEnumerable<Guid> initialChildrenKeysOfType);
|
|
List<Guid> initialChildrenOfTypeList = initialChildrenKeysOfType.ToList();
|
|
|
|
// Doc Type
|
|
var anotherContentType = ContentTypeBuilder.CreateSimpleContentType("anotherPage", "Another page");
|
|
anotherContentType.Key = new Guid("58A2958E-B34F-4289-A225-E99EEC2456AB");
|
|
anotherContentType.AllowedContentTypes = new[] { new ContentTypeSort(anotherContentType.Key, 0, anotherContentType.Alias) };
|
|
await ContentTypeService.CreateAsync(anotherContentType, Constants.Security.SuperUserKey);
|
|
|
|
// Update old doc type
|
|
ContentType.AllowedContentTypes = new[] { new ContentTypeSort(ContentType.Key, 0, ContentType.Alias), new ContentTypeSort(anotherContentType.Key, 1, anotherContentType.Alias) };
|
|
await ContentTypeService.UpdateAsync(ContentType, Constants.Security.SuperUserKey);
|
|
|
|
// Content
|
|
var child4Model = CreateContentCreateModel("Child 4", new Guid("11233548-2E87-4D3E-8FC4-4400F9DBEF56"), anotherContentType.Key, parentKey); // Using new doc type
|
|
await ContentEditingService.CreateAsync(child4Model, Constants.Security.SuperUserKey);
|
|
|
|
// Act
|
|
DocumentNavigationQueryService.TryGetChildrenKeysOfType(parentKey, anotherContentType.Alias, out IEnumerable<Guid> filteredChildrenKeysOfType);
|
|
List<Guid> filteredChildrenList = filteredChildrenKeysOfType.ToList();
|
|
|
|
DocumentNavigationQueryService.TryGetChildrenKeys(parentKey, out IEnumerable<Guid> allChildrenKeys);
|
|
List<Guid> allChildrenList = allChildrenKeys.ToList();
|
|
|
|
// Assert
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.AreEqual(3, initialChildrenOfTypeList.Count); // Verify that loaded doc types can be used to filter
|
|
Assert.AreEqual(1, filteredChildrenList.Count); // Verify that new doc type can be used to filter
|
|
Assert.AreEqual(4, allChildrenList.Count);
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public async Task Can_Filter_Descendants_By_Type()
|
|
{
|
|
// Arrange
|
|
Guid parentKey = Child2.Key;
|
|
DocumentNavigationQueryService.TryGetDescendantsKeysOfType(parentKey, ContentType.Alias, out IEnumerable<Guid> initialDescendantsKeysOfType);
|
|
List<Guid> initialDescendantsOfTypeList = initialDescendantsKeysOfType.ToList();
|
|
|
|
// Doc Type
|
|
var anotherContentType = ContentTypeBuilder.CreateSimpleContentType("anotherPage", "Another page");
|
|
anotherContentType.Key = new Guid("58A2958E-B34F-4289-A225-E99EEC2456AB");
|
|
anotherContentType.AllowedContentTypes = new[] { new ContentTypeSort(anotherContentType.Key, 0, anotherContentType.Alias) };
|
|
await ContentTypeService.CreateAsync(anotherContentType, Constants.Security.SuperUserKey);
|
|
|
|
// Update old doc type
|
|
ContentType.AllowedContentTypes = new[] { new ContentTypeSort(ContentType.Key, 0, ContentType.Alias), new ContentTypeSort(anotherContentType.Key, 1, anotherContentType.Alias) };
|
|
await ContentTypeService.UpdateAsync(ContentType, Constants.Security.SuperUserKey);
|
|
|
|
// Content
|
|
var greatGreatGrandchild1Model = CreateContentCreateModel("Great-great-grandchild 1", new Guid("11233548-2E87-4D3E-8FC4-4400F9DBEF56"), anotherContentType.Key, GreatGrandchild1.Key); // Using new doc type
|
|
await ContentEditingService.CreateAsync(greatGreatGrandchild1Model, Constants.Security.SuperUserKey);
|
|
|
|
// Act
|
|
DocumentNavigationQueryService.TryGetDescendantsKeysOfType(parentKey, anotherContentType.Alias, out IEnumerable<Guid> filteredDescendantsKeysOfType);
|
|
List<Guid> filteredDescendantsList = filteredDescendantsKeysOfType.ToList();
|
|
|
|
DocumentNavigationQueryService.TryGetDescendantsKeys(parentKey, out IEnumerable<Guid> allDescendantsKeys);
|
|
List<Guid> allDescendantsList = allDescendantsKeys.ToList();
|
|
|
|
// Assert
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.AreEqual(2, initialDescendantsOfTypeList.Count); // Verify that loaded doc types can be used to filter
|
|
Assert.AreEqual(1, filteredDescendantsList.Count); // Verify that new doc type can be used to filter
|
|
Assert.AreEqual(3, allDescendantsList.Count);
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public async Task Can_Filter_Ancestors_By_Type()
|
|
{
|
|
// Arrange
|
|
Guid childKey = new Guid("1802D6B4-4A3C-4EBA-AFA3-1AF82C2D6483");
|
|
|
|
// Doc Type
|
|
var anotherContentType = ContentTypeBuilder.CreateSimpleContentType("anotherPage", "Another page");
|
|
anotherContentType.Key = new Guid("58A2958E-B34F-4289-A225-E99EEC2456AB");
|
|
anotherContentType.AllowedContentTypes = new[] { new ContentTypeSort(anotherContentType.Key, 0, anotherContentType.Alias) };
|
|
await ContentTypeService.CreateAsync(anotherContentType, Constants.Security.SuperUserKey);
|
|
|
|
// Update old doc type
|
|
ContentType.AllowedContentTypes = new[] { new ContentTypeSort(ContentType.Key, 0, ContentType.Alias), new ContentTypeSort(anotherContentType.Key, 1, anotherContentType.Alias) };
|
|
await ContentTypeService.UpdateAsync(ContentType, Constants.Security.SuperUserKey);
|
|
|
|
// Content
|
|
var greatGrandchild2Model = CreateContentCreateModel("Great-grandchild 2", new Guid("11233548-2E87-4D3E-8FC4-4400F9DBEF56"), anotherContentType.Key, Grandchild4.Key); // Using new doc type
|
|
await ContentEditingService.CreateAsync(greatGrandchild2Model, Constants.Security.SuperUserKey);
|
|
var greatGreatGrandchild1Model = CreateContentCreateModel("Great-great-grandchild 1", childKey, anotherContentType.Key, greatGrandchild2Model.Key); // Using new doc type
|
|
await ContentEditingService.CreateAsync(greatGreatGrandchild1Model, Constants.Security.SuperUserKey);
|
|
|
|
// Act
|
|
DocumentNavigationQueryService.TryGetAncestorsKeysOfType(childKey, ContentType.Alias, out IEnumerable<Guid> ancestorsKeysOfOriginalType);
|
|
List<Guid> ancestorsKeysOfOriginalTypeList = ancestorsKeysOfOriginalType.ToList();
|
|
|
|
DocumentNavigationQueryService.TryGetAncestorsKeysOfType(childKey, anotherContentType.Alias, out IEnumerable<Guid> ancestorsKeysOfNewType);
|
|
List<Guid> ancestorsKeysOfNewTypeList = ancestorsKeysOfNewType.ToList();
|
|
|
|
DocumentNavigationQueryService.TryGetAncestorsKeys(childKey, out IEnumerable<Guid> allAncestorsKeys);
|
|
List<Guid> allAncestorsList = allAncestorsKeys.ToList();
|
|
|
|
// Assert
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.AreEqual(3, ancestorsKeysOfOriginalTypeList.Count); // Verify that loaded doc types can be used to filter
|
|
Assert.AreEqual(1, ancestorsKeysOfNewTypeList.Count); // Verify that new doc type can be used to filter
|
|
Assert.AreEqual(4, allAncestorsList.Count);
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public async Task Can_Filter_Siblings_By_Type()
|
|
{
|
|
// Arrange
|
|
Guid parentKey = Child3.Key;
|
|
DocumentNavigationQueryService.TryGetSiblingsKeysOfType(parentKey, ContentType.Alias, out IEnumerable<Guid> initialSiblingsKeysOfType);
|
|
List<Guid> initialSiblingsOfTypeList = initialSiblingsKeysOfType.ToList();
|
|
|
|
// Doc Type
|
|
var anotherContentType = ContentTypeBuilder.CreateSimpleContentType("anotherPage", "Another page");
|
|
anotherContentType.Key = new Guid("58A2958E-B34F-4289-A225-E99EEC2456AB");
|
|
anotherContentType.AllowedContentTypes = new[] { new ContentTypeSort(anotherContentType.Key, 0, anotherContentType.Alias) };
|
|
await ContentTypeService.CreateAsync(anotherContentType, Constants.Security.SuperUserKey);
|
|
|
|
// Update old doc type
|
|
ContentType.AllowedContentTypes = new[] { new ContentTypeSort(ContentType.Key, 0, ContentType.Alias), new ContentTypeSort(anotherContentType.Key, 1, anotherContentType.Alias) };
|
|
await ContentTypeService.UpdateAsync(ContentType, Constants.Security.SuperUserKey);
|
|
|
|
// Content
|
|
var child4Model = CreateContentCreateModel("Child 4", new Guid("11233548-2E87-4D3E-8FC4-4400F9DBEF56"), anotherContentType.Key, Root.Key); // Using new doc type
|
|
await ContentEditingService.CreateAsync(child4Model, Constants.Security.SuperUserKey);
|
|
|
|
// Act
|
|
DocumentNavigationQueryService.TryGetSiblingsKeysOfType(parentKey, anotherContentType.Alias, out IEnumerable<Guid> filteredSiblingsKeysOfType);
|
|
List<Guid> filteredSiblingsList = filteredSiblingsKeysOfType.ToList();
|
|
|
|
DocumentNavigationQueryService.TryGetSiblingsKeys(parentKey, out IEnumerable<Guid> allSiblingsKeys);
|
|
List<Guid> allSiblingsList = allSiblingsKeys.ToList();
|
|
|
|
// Assert
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.AreEqual(2, initialSiblingsOfTypeList.Count); // Verify that loaded doc types can be used to filter
|
|
Assert.AreEqual(1, filteredSiblingsList.Count); // Verify that new doc type can be used to filter
|
|
Assert.AreEqual(3, allSiblingsList.Count);
|
|
});
|
|
}
|
|
|
|
// a lot of structural querying assumes a specific order of descendants, so let's ensure that.
|
|
[Test]
|
|
public void Descendants_Are_In_Top_Down_Order_Of_Structure()
|
|
{
|
|
var result = DocumentNavigationQueryService.TryGetDescendantsKeysOrSelfKeys(Root.Key, out IEnumerable<Guid> descendantsKeys);
|
|
Assert.IsTrue(result);
|
|
|
|
var descendantsKeysAsArray = descendantsKeys.ToArray();
|
|
Assert.AreEqual(9, descendantsKeysAsArray.Length);
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.AreEqual(Root.Key, descendantsKeysAsArray[0]);
|
|
Assert.AreEqual(Child1.Key, descendantsKeysAsArray[1]);
|
|
Assert.AreEqual(Grandchild1.Key, descendantsKeysAsArray[2]);
|
|
Assert.AreEqual(Grandchild2.Key, descendantsKeysAsArray[3]);
|
|
Assert.AreEqual(Child2.Key, descendantsKeysAsArray[4]);
|
|
Assert.AreEqual(Grandchild3.Key, descendantsKeysAsArray[5]);
|
|
Assert.AreEqual(GreatGrandchild1.Key, descendantsKeysAsArray[6]);
|
|
Assert.AreEqual(Child3.Key, descendantsKeysAsArray[7]);
|
|
Assert.AreEqual(Grandchild4.Key, descendantsKeysAsArray[8]);
|
|
});
|
|
}
|
|
|
|
// a lot of structural querying assumes a specific order of ancestors, so let's ensure that.
|
|
[Test]
|
|
public void Ancestors_Are_In_Down_Top_Order()
|
|
{
|
|
var result = DocumentNavigationQueryService.TryGetAncestorsOrSelfKeys(GreatGrandchild1.Key, out IEnumerable<Guid> ancestorsKeys);
|
|
Assert.IsTrue(result);
|
|
|
|
var ancestorKeysAsArray = ancestorsKeys.ToArray();
|
|
Assert.AreEqual(4, ancestorKeysAsArray.Length);
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.AreEqual(GreatGrandchild1.Key, ancestorKeysAsArray[0]);
|
|
Assert.AreEqual(Grandchild3.Key, ancestorKeysAsArray[1]);
|
|
Assert.AreEqual(Child2.Key, ancestorKeysAsArray[2]);
|
|
Assert.AreEqual(Root.Key, ancestorKeysAsArray[3]);
|
|
});
|
|
}
|
|
}
|