2020-12-09 22:43:49 +11:00
|
|
|
using System;
|
2018-04-29 20:02:38 +02:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2020-12-09 22:43:49 +11:00
|
|
|
using Umbraco.Core.Models;
|
2019-12-10 08:37:19 +01:00
|
|
|
using Umbraco.Core.Models.PublishedContent;
|
2018-04-29 20:02:38 +02:00
|
|
|
using Umbraco.Core.Scoping;
|
2020-12-09 22:43:49 +11:00
|
|
|
using Umbraco.Infrastructure.PublishedCache.Persistence;
|
2019-10-22 00:53:52 +11:00
|
|
|
using Umbraco.Web;
|
2018-04-29 20:02:38 +02:00
|
|
|
using Umbraco.Web.PublishedCache.NuCache;
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Tests.Testing.Objects
|
|
|
|
|
{
|
2019-10-22 00:53:52 +11:00
|
|
|
|
2020-12-09 22:43:49 +11:00
|
|
|
internal class TestDataSource : INuCacheContentService
|
2018-04-29 20:02:38 +02:00
|
|
|
{
|
2019-12-10 08:37:19 +01:00
|
|
|
|
|
|
|
|
private IPublishedModelFactory PublishedModelFactory { get; } = new NoopPublishedModelFactory();
|
|
|
|
|
|
2018-04-29 20:02:38 +02:00
|
|
|
public TestDataSource(params ContentNodeKit[] kits)
|
|
|
|
|
: this((IEnumerable<ContentNodeKit>) kits)
|
|
|
|
|
{ }
|
|
|
|
|
|
2020-12-09 22:43:49 +11:00
|
|
|
public TestDataSource(IEnumerable<ContentNodeKit> kits) => Kits = kits.ToDictionary(x => x.Node.Id, x => x);
|
2018-04-29 20:02:38 +02:00
|
|
|
|
2019-05-29 16:48:20 +02:00
|
|
|
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
|
2020-12-09 22:43:49 +11:00
|
|
|
public ContentNodeKit GetContentSource(int id)
|
|
|
|
|
=> Kits.TryGetValue(id, out ContentNodeKit kit) ? kit.Clone(PublishedModelFactory) : default;
|
2019-05-29 16:48:20 +02:00
|
|
|
|
2020-12-09 22:43:49 +11:00
|
|
|
public IEnumerable<ContentNodeKit> GetAllContentSources()
|
2019-05-29 16:48:20 +02:00
|
|
|
=> Kits.Values
|
|
|
|
|
.OrderBy(x => x.Node.Level)
|
2019-08-19 17:18:45 +10:00
|
|
|
.ThenBy(x => x.Node.ParentContentId)
|
|
|
|
|
.ThenBy(x => x.Node.SortOrder)
|
2019-12-10 08:37:19 +01:00
|
|
|
.Select(x => x.Clone(PublishedModelFactory));
|
2018-04-29 20:02:38 +02:00
|
|
|
|
2020-12-09 22:43:49 +11:00
|
|
|
public IEnumerable<ContentNodeKit> GetBranchContentSources(int id)
|
2019-05-29 16:48:20 +02:00
|
|
|
=> Kits.Values
|
|
|
|
|
.Where(x => x.Node.Path.EndsWith("," + id) || x.Node.Path.Contains("," + id + ","))
|
2019-08-19 17:18:45 +10:00
|
|
|
.OrderBy(x => x.Node.Level)
|
|
|
|
|
.ThenBy(x => x.Node.ParentContentId)
|
|
|
|
|
.ThenBy(x => x.Node.SortOrder)
|
2019-12-10 08:37:19 +01:00
|
|
|
.Select(x => x.Clone(PublishedModelFactory));
|
2018-04-29 20:02:38 +02:00
|
|
|
|
2020-12-09 22:43:49 +11:00
|
|
|
public IEnumerable<ContentNodeKit> GetTypeContentSources(IEnumerable<int> ids)
|
2019-05-29 16:48:20 +02:00
|
|
|
=> Kits.Values
|
|
|
|
|
.Where(x => ids.Contains(x.ContentTypeId))
|
2019-08-19 17:18:45 +10:00
|
|
|
.OrderBy(x => x.Node.Level)
|
|
|
|
|
.ThenBy(x => x.Node.ParentContentId)
|
|
|
|
|
.ThenBy(x => x.Node.SortOrder)
|
2019-12-10 08:37:19 +01:00
|
|
|
.Select(x => x.Clone(PublishedModelFactory));
|
2018-04-29 20:02:38 +02:00
|
|
|
|
2020-12-09 22:43:49 +11:00
|
|
|
public ContentNodeKit GetMediaSource(int id) => default;
|
2018-04-29 20:02:38 +02:00
|
|
|
|
2020-12-09 22:43:49 +11:00
|
|
|
public IEnumerable<ContentNodeKit> GetAllMediaSources() => Enumerable.Empty<ContentNodeKit>();
|
2018-04-29 20:02:38 +02:00
|
|
|
|
2020-12-09 22:43:49 +11:00
|
|
|
public IEnumerable<ContentNodeKit> GetBranchMediaSources(int id) => Enumerable.Empty<ContentNodeKit>();
|
2018-04-29 20:02:38 +02:00
|
|
|
|
2020-12-09 22:43:49 +11:00
|
|
|
public IEnumerable<ContentNodeKit> GetTypeMediaSources(IEnumerable<int> ids) => Enumerable.Empty<ContentNodeKit>();
|
|
|
|
|
public void DeleteContentItem(IContentBase item) => throw new NotImplementedException();
|
|
|
|
|
public void RefreshContent(IContent content) => throw new NotImplementedException();
|
|
|
|
|
public void RefreshEntity(IContentBase content) => throw new NotImplementedException();
|
|
|
|
|
public bool VerifyContentDbCache() => throw new NotImplementedException();
|
|
|
|
|
public bool VerifyMediaDbCache() => throw new NotImplementedException();
|
|
|
|
|
public bool VerifyMemberDbCache() => throw new NotImplementedException();
|
|
|
|
|
public void Rebuild(int groupSize = 5000, IReadOnlyCollection<int> contentTypeIds = null, IReadOnlyCollection<int> mediaTypeIds = null, IReadOnlyCollection<int> memberTypeIds = null) => throw new NotImplementedException();
|
2018-04-29 20:02:38 +02:00
|
|
|
}
|
|
|
|
|
}
|