Files
Umbraco-CMS/tests/Umbraco.Tests.Integration/Umbraco.Core/Services/DocumentNavigationServiceTestsBase.cs
Bjarke Berg 04ba12297f Handle navigation updates in cache refeshers (#17161)
* Handle navigation updates in cache refeshers

* Same for media cache refreshers

* Clean up

* More clean up and renaming content to media

* Update src/Umbraco.Core/Services/Navigation/ContentNavigationServiceBase.cs

Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>

---------

Co-authored-by: Elitsa <elm@umbraco.dk>
Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>
2024-09-30 16:43:05 +02:00

63 lines
2.2 KiB
C#

using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Services.Navigation;
using Umbraco.Cms.Core.Sync;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;
using Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Scoping;
namespace Umbraco.Cms.Tests.Integration.Umbraco.Core.Services;
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public abstract class DocumentNavigationServiceTestsBase : UmbracoIntegrationTest
{
protected IContentTypeService ContentTypeService => GetRequiredService<IContentTypeService>();
// Testing with IContentEditingService as it calls IContentService underneath
protected IContentEditingService ContentEditingService => GetRequiredService<IContentEditingService>();
protected IDocumentNavigationQueryService DocumentNavigationQueryService => GetRequiredService<IDocumentNavigationQueryService>();
protected IContentType ContentType { get; set; }
protected IContent Root { get; set; }
protected IContent Child1 { get; set; }
protected IContent Grandchild1 { get; set; }
protected IContent Grandchild2 { get; set; }
protected IContent Child2 { get; set; }
protected IContent Grandchild3 { get; set; }
protected IContent GreatGrandchild1 { get; set; }
protected IContent Child3 { get; set; }
protected IContent Grandchild4 { get; set; }
protected ContentCreateModel CreateContentCreateModel(string name, Guid key, Guid? parentKey = null)
=> new()
{
ContentTypeKey = ContentType.Key,
ParentKey = parentKey ?? Constants.System.RootKey,
InvariantName = name,
Key = key,
};
protected override void CustomTestSetup(IUmbracoBuilder builder)
{
builder.Services.AddUnique<IServerMessenger, ScopedRepositoryTests.LocalServerMessenger>();
builder.AddNotificationHandler<ContentTreeChangeNotification, ContentTreeChangeDistributedCacheNotificationHandler>();
}
}