V16: Siblings endpoints (#19657)
* PoC implementation * Move to controller base * Implement solution that seems worse, but works better * Don't require parent key in repository method * Fix typos * Add siblings for data type, media type and media * Add endpoint for template * Add DocumentType and DocumentBlueprint controllers * Fix naming * Fix case if siblings are under root * Take item ordering into account not all entities are ordered by sort order * Add default implementation * Fix parentkey * Add tests * Format optimizations for split view * Add test covered requirement to description * Cover positive case and make test case output more readable * reduce allocations * Clarify test --------- Co-authored-by: Migaroez <geusens@gmail.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private EntityService CreateEntityService() =>
|
||||
new(
|
||||
Mock.Of<ICoreScopeProvider>(),
|
||||
Mock.Of<ILoggerFactory>(),
|
||||
Mock.Of<IEventMessagesFactory>(),
|
||||
Mock.Of<IIdKeyMap>(),
|
||||
Mock.Of<IEntityRepository>());
|
||||
}
|
||||
Reference in New Issue
Block a user