refactor(core): delegate GetByLevel to QueryOperationService
ContentService.GetByLevel now delegates to QueryOperationService, continuing Phase 2 query operation extraction. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -614,14 +614,7 @@ public class ContentService : RepositoryService, IContentService
|
|||||||
/// <returns>An Enumerable list of <see cref="IContent" /> objects</returns>
|
/// <returns>An Enumerable list of <see cref="IContent" /> objects</returns>
|
||||||
/// <remarks>Contrary to most methods, this method filters out trashed content items.</remarks>
|
/// <remarks>Contrary to most methods, this method filters out trashed content items.</remarks>
|
||||||
public IEnumerable<IContent> GetByLevel(int level)
|
public IEnumerable<IContent> GetByLevel(int level)
|
||||||
{
|
=> QueryOperationService.GetByLevel(level);
|
||||||
using (ICoreScope scope = ScopeProvider.CreateCoreScope(autoComplete: true))
|
|
||||||
{
|
|
||||||
scope.ReadLock(Constants.Locks.ContentTree);
|
|
||||||
IQuery<IContent>? query = Query<IContent>().Where(x => x.Level == level && x.Trashed == false);
|
|
||||||
return _documentRepository.Get(query);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a specific version of an <see cref="IContent" /> item.
|
/// Gets a specific version of an <see cref="IContent" /> item.
|
||||||
|
|||||||
@@ -746,6 +746,24 @@ internal sealed class ContentServiceRefactoringTests : UmbracoIntegrationTestWit
|
|||||||
Assert.That(facadeCount, Is.EqualTo(directCount));
|
Assert.That(facadeCount, Is.EqualTo(directCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Phase 2 Test: Verifies GetByLevel() via facade returns same result as direct service call.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void GetByLevel_ViaFacade_ReturnsEquivalentResultToDirectService()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var queryService = GetRequiredService<IContentQueryOperationService>();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var facadeItems = ContentService.GetByLevel(1).ToList();
|
||||||
|
var directItems = queryService.GetByLevel(1).ToList();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.That(facadeItems.Count, Is.EqualTo(directItems.Count));
|
||||||
|
Assert.That(facadeItems.Select(x => x.Id), Is.EquivalentTo(directItems.Select(x => x.Id)));
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user