# Conflicts: # src/Umbraco.Core/Persistence/Repositories/Implement/ContentRepositoryBase.cs # src/Umbraco.Core/Persistence/Repositories/Implement/DocumentBlueprintRepository.cs # src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs # src/Umbraco.Core/Persistence/Repositories/Implement/MediaRepository.cs # src/Umbraco.Core/Persistence/Repositories/Implement/MemberRepository.cs # src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs # src/Umbraco.Tests/Persistence/Repositories/DocumentRepositoryTest.cs # src/Umbraco.Tests/Persistence/Repositories/DomainRepositoryTest.cs # src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs # src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs # src/Umbraco.Tests/Persistence/Repositories/PublicAccessRepositoryTest.cs # src/Umbraco.Tests/Persistence/Repositories/TagRepositoryTest.cs # src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs # src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs # src/Umbraco.Tests/Published/NestedContentTests.cs # src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs # src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs # src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs # src/Umbraco.Tests/Services/ContentServiceTests.cs # src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs # src/Umbraco.Web/PropertyEditors/ContentPickerPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/GridPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/MediaPickerPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/MultiUrlPickerPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs
79 lines
2.8 KiB
C#
79 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Umbraco.Core.Models.PublishedContent;
|
|
using Umbraco.Core.Scoping;
|
|
using Umbraco.Web;
|
|
using Umbraco.Web.PublishedCache.NuCache;
|
|
using Umbraco.Web.PublishedCache.NuCache.DataSource;
|
|
|
|
namespace Umbraco.Tests.Testing.Objects
|
|
{
|
|
|
|
internal class TestDataSource : IDataSource
|
|
{
|
|
|
|
private IPublishedModelFactory PublishedModelFactory { get; } = new NoopPublishedModelFactory();
|
|
|
|
public TestDataSource(params ContentNodeKit[] kits)
|
|
: this((IEnumerable<ContentNodeKit>) kits)
|
|
{ }
|
|
|
|
public TestDataSource(IEnumerable<ContentNodeKit> kits)
|
|
{
|
|
Kits = kits.ToDictionary(x => x.Node.Id, x => x);
|
|
}
|
|
|
|
public Dictionary<int, ContentNodeKit> Kits { get; }
|
|
|
|
// note: it is important to clone the returned kits, as the inner
|
|
// ContentNode is directly reused and modified by the snapshot service
|
|
|
|
public ContentNodeKit GetContentSource(IScope scope, int id)
|
|
=> Kits.TryGetValue(id, out var kit) ? kit.Clone(PublishedModelFactory) : default;
|
|
|
|
public IEnumerable<ContentNodeKit> GetAllContentSources(IScope scope)
|
|
=> Kits.Values
|
|
.OrderBy(x => x.Node.Level)
|
|
.ThenBy(x => x.Node.ParentContentId)
|
|
.ThenBy(x => x.Node.SortOrder)
|
|
.Select(x => x.Clone(PublishedModelFactory));
|
|
|
|
public IEnumerable<ContentNodeKit> GetBranchContentSources(IScope scope, int id)
|
|
=> Kits.Values
|
|
.Where(x => x.Node.Path.EndsWith("," + id) || x.Node.Path.Contains("," + id + ","))
|
|
.OrderBy(x => x.Node.Level)
|
|
.ThenBy(x => x.Node.ParentContentId)
|
|
.ThenBy(x => x.Node.SortOrder)
|
|
.Select(x => x.Clone(PublishedModelFactory));
|
|
|
|
public IEnumerable<ContentNodeKit> GetTypeContentSources(IScope scope, IEnumerable<int> ids)
|
|
=> Kits.Values
|
|
.Where(x => ids.Contains(x.ContentTypeId))
|
|
.OrderBy(x => x.Node.Level)
|
|
.ThenBy(x => x.Node.ParentContentId)
|
|
.ThenBy(x => x.Node.SortOrder)
|
|
.Select(x => x.Clone(PublishedModelFactory));
|
|
|
|
public ContentNodeKit GetMediaSource(IScope scope, int id)
|
|
{
|
|
return default;
|
|
}
|
|
|
|
public IEnumerable<ContentNodeKit> GetAllMediaSources(IScope scope)
|
|
{
|
|
return Enumerable.Empty<ContentNodeKit>();
|
|
}
|
|
|
|
public IEnumerable<ContentNodeKit> GetBranchMediaSources(IScope scope, int id)
|
|
{
|
|
return Enumerable.Empty<ContentNodeKit>();
|
|
}
|
|
|
|
public IEnumerable<ContentNodeKit> GetTypeMediaSources(IScope scope, IEnumerable<int> ids)
|
|
{
|
|
return Enumerable.Empty<ContentNodeKit>();
|
|
}
|
|
}
|
|
}
|