Files
Umbraco-CMS/tests/Umbraco.Tests/Testing/Objects/TestDataSource.cs

68 lines
3.4 KiB
C#
Raw Normal View History

using System;
2018-04-29 20:02:38 +02:00
using System.Collections.Generic;
using System.Linq;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Infrastructure.PublishedCache;
using Umbraco.Cms.Infrastructure.PublishedCache.Persistence;
2018-04-29 20:02:38 +02:00
namespace Umbraco.Tests.Testing.Objects
{
internal class TestDataSource : INuCacheContentService
2018-04-29 20:02:38 +02:00
{
private IPublishedModelFactory PublishedModelFactory { get; } = new NoopPublishedModelFactory();
2018-04-29 20:02:38 +02:00
public TestDataSource(params ContentNodeKit[] kits)
: this((IEnumerable<ContentNodeKit>) kits)
{ }
public TestDataSource(IEnumerable<ContentNodeKit> kits) => Kits = kits.ToDictionary(x => x.Node.Id, x => x);
2018-04-29 20:02:38 +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
public ContentNodeKit GetContentSource(int id)
=> Kits.TryGetValue(id, out ContentNodeKit kit) ? kit.Clone(PublishedModelFactory) : default;
public IEnumerable<ContentNodeKit> GetAllContentSources()
=> 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)
.Select(x => x.Clone(PublishedModelFactory));
2018-04-29 20:02:38 +02:00
public IEnumerable<ContentNodeKit> GetBranchContentSources(int id)
=> 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)
.Select(x => x.Clone(PublishedModelFactory));
2018-04-29 20:02:38 +02:00
public IEnumerable<ContentNodeKit> GetTypeContentSources(IEnumerable<int> ids)
=> 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)
.Select(x => x.Clone(PublishedModelFactory));
2018-04-29 20:02:38 +02:00
public ContentNodeKit GetMediaSource(int id) => default;
2018-04-29 20:02:38 +02:00
public IEnumerable<ContentNodeKit> GetAllMediaSources() => Enumerable.Empty<ContentNodeKit>();
2018-04-29 20:02:38 +02:00
public IEnumerable<ContentNodeKit> GetBranchMediaSources(int id) => Enumerable.Empty<ContentNodeKit>();
2018-04-29 20:02:38 +02:00
public IEnumerable<ContentNodeKit> GetTypeMediaSources(IEnumerable<int> ids) => Enumerable.Empty<ContentNodeKit>();
public void DeleteContentItem(IContentBase item) => throw new NotImplementedException();
Netcore: Migrate RepositoryBase and ContentTypeServiceBase events (#10141) * Remove ScopeEntityRemove from ContentRepositoryBase and rely on "ing" notifications * Remove old event handler from ContentEventsTests * Remove ScopedVersionRemove from ContentRepositoryBase and rely on service notifications instead * Remove unused ScopedVersionEventArgs from ContentRepositoryBase * Migrate ScopeEntityRefresh to notification pattern Unfortunately it's still published from the repository base * Add simple content type notifications * Publish Notifications instead of events in ContentTypeServiceBase for simple events * Switch OnChanged to use Notifications for ContentTypeServices * Publish notifications instead of raising ScopedRefreshedEntity on ContentTypeServiceBase * Hook up to the new ContentType notifications * Remove DistributedCacheBinderTests There are no longer any events to really test on. * Remove ContentTypeChange EventArgs * Remove ContentService_Copied from DistributedCacheBinder It's no longer used * Cleanup * Cleanup * Removed uncommented code * Fixed issue with unattented installs * Re-add ContentTreeChangeNotification to DistributedCache * Add new notification for ScopedEntityRemove Marked as obsolete/hidden in editor, since this should only be used for nucache for now, and should really be changed in the future * Mark Refresh notifications as obsolete/hidden These should not be used anywhere outside Nucache, and should be changed to tree change at some point. * Raise ScopedEntityRemoveNotification on repos and use in nucache Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-04-20 12:17:11 +02:00
public void DeleteContentItems(IEnumerable<IContentBase> items) => 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
}
}