Introduced NoopServerMessenger for integration tests

Signed-off-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
Bjarke Berg
2020-10-05 16:59:26 +02:00
parent 696c65222f
commit 471903b793
2 changed files with 55 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
using Moq;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Extensions.Options;
@@ -14,6 +15,7 @@ using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
using Umbraco.Core.Sync;
using Umbraco.Core.WebAssets;
using Umbraco.Examine;
using Umbraco.Web.Compose;
@@ -50,6 +52,10 @@ namespace Umbraco.Tests.Integration.Testing
// replace this service so that it can lookup the correct file locations
composition.RegisterUnique<ILocalizedTextService>(GetLocalizedTextService);
composition.RegisterUnique<IServerMessenger, NoopServerMessenger>();
}
/// <summary>
@@ -100,5 +106,51 @@ namespace Umbraco.Tests.Integration.Testing
}
}
private class NoopServerMessenger : IServerMessenger
{
public NoopServerMessenger()
{ }
public void PerformRefresh<TPayload>(ICacheRefresher refresher, TPayload[] payload)
{
}
public void PerformRefresh<T>(ICacheRefresher refresher, Func<T, int> getNumericId, params T[] instances)
{
}
public void PerformRefresh<T>(ICacheRefresher refresher, Func<T, Guid> getGuidId, params T[] instances)
{
}
public void PerformRemove<T>(ICacheRefresher refresher, Func<T, int> getNumericId, params T[] instances)
{
}
public void PerformRemove(ICacheRefresher refresher, params int[] numericIds)
{
}
public void PerformRefresh(ICacheRefresher refresher, params int[] numericIds)
{
}
public void PerformRefresh(ICacheRefresher refresher, params Guid[] guidIds)
{
}
public void PerformRefreshAll(ICacheRefresher refresher)
{
}
}
}
}

View File

@@ -247,6 +247,7 @@ namespace Umbraco.Tests.Integration.Testing
CustomTestSetup(services);
}
public virtual void Configure(IApplicationBuilder app)
{
Services.GetRequiredService<IBackofficeSecurityFactory>().EnsureBackofficeSecurity();
@@ -349,10 +350,6 @@ namespace Umbraco.Tests.Integration.Testing
OnTestTearDown(() =>
{
db.Detach(newSchemaDbId);
var caches = GetRequiredService<AppCaches>();
caches.IsolatedCaches.ClearAllCaches();
caches.RuntimeCache.Clear();
caches.RequestCache.Clear();
});
// We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings
@@ -391,10 +388,6 @@ namespace Umbraco.Tests.Integration.Testing
OnFixtureTearDown(() =>
{
db.Detach(newSchemaFixtureDbId);
var caches = GetRequiredService<AppCaches>();
caches.IsolatedCaches.ClearAllCaches();
caches.RuntimeCache.Clear();
caches.RequestCache.Clear();
});
}