* Adds support for the "folders only" flag on retrieving siblings of a node. * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Updated test code. * Removed double secondary ordering by node Id and ensured we include this clause for all sort orders. * Ensure that ordering by node Id is always added only once and last, and only if it's not already been included in the order by clause. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.Extensions.Logging;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using Umbraco.Cms.Core.Events;
|
|
using Umbraco.Cms.Core.Models;
|
|
using Umbraco.Cms.Core.Persistence.Repositories;
|
|
using Umbraco.Cms.Core.Scoping;
|
|
using Umbraco.Cms.Core.Services;
|
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Services;
|
|
|
|
[TestFixture]
|
|
public class EntityServiceTests
|
|
{
|
|
[TestCase(1, 1, false, TestName = "Siblings_Index_Validation_Valid")]
|
|
[TestCase(-1, 1, true, TestName = "Siblings_Index_Validation_InvalidBefore")]
|
|
[TestCase(1, -1, true, TestName = "Siblings_Index_Validation_InvalidAfter")]
|
|
[TestCase(-1, -1, true, TestName = "Siblings_Index_Validation_InvalidBeforeAndAfter")]
|
|
public void Siblings_Index_Validation(int before, int after, bool shouldThrow)
|
|
{
|
|
var sut = CreateEntityService();
|
|
|
|
if (shouldThrow)
|
|
{
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => sut.GetSiblings(Guid.NewGuid(), [UmbracoObjectTypes.Document], before, after, out _, out _));
|
|
}
|
|
}
|
|
|
|
|
|
private EntityService CreateEntityService() =>
|
|
new(
|
|
Mock.Of<ICoreScopeProvider>(),
|
|
Mock.Of<ILoggerFactory>(),
|
|
Mock.Of<IEventMessagesFactory>(),
|
|
Mock.Of<IIdKeyMap>(),
|
|
Mock.Of<IEntityRepository>());
|
|
}
|