Changes CustomTestSetup to just be a normal method, not sure why it was an action, fixes ContentEventsTests which requires NuCache

This commit is contained in:
Shannon
2020-12-23 13:57:41 +11:00
parent d5a19530f3
commit 534b74dda5
5 changed files with 19 additions and 29 deletions

View File

@@ -24,9 +24,8 @@ namespace Umbraco.Tests.Testing
public bool Mapper { get => _mapper.ValueOrDefault(WithApplication); set => _mapper.Set(value); }
private readonly Settable<bool> _mapper = new Settable<bool>();
// FIXME: to be completed
/// <summary>
/// Gets or sets a value indicating ...
/// Gets or sets a value indicating whether the LEGACY XML Cache used in tests should bind to repository events
/// </summary>
public bool PublishedRepositoryEvents { get => _publishedRepositoryEvents.ValueOrDefault(false); set => _publishedRepositoryEvents.Set(value); }
private readonly Settable<bool> _publishedRepositoryEvents = new Settable<bool>();

View File

@@ -25,6 +25,7 @@ using Umbraco.Core.Runtime;
using Umbraco.Core.Scoping;
using Umbraco.Core.Strings;
using Umbraco.Extensions;
using Umbraco.Infrastructure.PublishedCache.DependencyInjection;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Integration.Extensions;
using Umbraco.Tests.Integration.Implementations;
@@ -232,7 +233,7 @@ namespace Umbraco.Tests.Integration.Testing
builder.Build();
CustomTestSetup(services);
CustomTestSetup(builder);
}
protected virtual AppCaches GetAppCaches()
@@ -402,7 +403,7 @@ namespace Umbraco.Tests.Integration.Testing
public TestHelper TestHelper { get; } = new TestHelper();
protected virtual Action<IServiceCollection> CustomTestSetup => services => { };
protected virtual void CustomTestSetup(IUmbracoBuilder builder) { }
/// <summary>
/// Returns the DI container

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
@@ -6,6 +6,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
using NUnit.Framework;
using Umbraco.Core.Cache;
using Umbraco.Core.DependencyInjection;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Membership;
@@ -31,8 +32,8 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Scoping
private IServerMessenger ServerMessenger => GetRequiredService<IServerMessenger>();
private CacheRefresherCollection CacheRefresherCollection => GetRequiredService<CacheRefresherCollection>();
protected override Action<IServiceCollection> CustomTestSetup => (services)
=> services.Replace(ServiceDescriptor.Singleton(typeof(IServerMessenger), typeof(LocalServerMessenger)));
protected override void CustomTestSetup(IUmbracoBuilder builder)
=> builder.Services.Replace(ServiceDescriptor.Singleton(typeof(IServerMessenger), typeof(LocalServerMessenger)));
protected override AppCaches GetAppCaches()
{

View File

@@ -1,17 +1,20 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Logging;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Microsoft.Extensions.Logging;
using Umbraco.Core.DependencyInjection;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Repositories.Implement;
using Umbraco.Core.Sync;
using Umbraco.Infrastructure.PublishedCache.DependencyInjection;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
using Umbraco.Web;
using Umbraco.Web.BackOffice.DependencyInjection;
using Umbraco.Web.Cache;
namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
@@ -21,14 +24,13 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
public class ContentEventsTests : UmbracoIntegrationTestWithContent
{
private CacheRefresherCollection CacheRefresherCollection => GetRequiredService<CacheRefresherCollection>();
private IUmbracoContextFactory UmbracoContextFactory => GetRequiredService<IUmbracoContextFactory>();
private ILogger<ContentEventsTests> Logger => GetRequiredService<ILogger<ContentEventsTests>>();
#region Setup
// trace ContentRepository unit-of-work events (refresh, remove), and ContentCacheRefresher CacheUpdated event
//
[SetUp]
public void SetUp()
{
@@ -52,19 +54,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
ContentTypeService.Save(_contentType);
}
// protected override void Compose()
// {
// base.Compose();
//
// Composition.Register<IServerRegistrar>(_ => new TestServerRegistrar()); // localhost-only
// composition.Services.AddUnique<IServerMessenger, LocalServerMessenger>();
//
// Composition.WithCollectionBuilder<CacheRefresherCollectionBuilder>()
// .Add<ContentTypeCacheRefresher>()
// .Add<ContentCacheRefresher>()
// .Add<MacroCacheRefresher>();
// }
protected override void CustomTestSetup(IUmbracoBuilder builder) => builder.AddNuCache();
[TearDown]
public void TearDownTest()

View File

@@ -1,17 +1,18 @@
using System;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using Umbraco.Core.DependencyInjection;
using Umbraco.Core.Security;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Web.BackOffice.DependencyInjection;
using Umbraco.Web.Common.Security;
namespace Umbraco.Tests.Integration.Umbraco.Web.BackOffice
{
[TestFixture]
public class UmbracoBackOfficeServiceCollectionExtensionsTests : UmbracoIntegrationTest
{
protected override void CustomTestSetup(IUmbracoBuilder builder) => builder.Services.AddUmbracoBackOfficeIdentity();
[Test]
public void AddUmbracoBackOfficeIdentity_ExpectBackOfficeUserStoreResolvable()
{
@@ -37,7 +38,5 @@ namespace Umbraco.Tests.Integration.Umbraco.Web.BackOffice
Assert.NotNull(userManager);
}
protected override Action<IServiceCollection> CustomTestSetup => (services) => services.AddUmbracoBackOfficeIdentity();
}
}