Merge remote-tracking branch 'origin/netcore/netcore' into netcore/feature/migrate-logging

Signed-off-by: Bjarke Berg <mail@bergmania.dk>

# Conflicts:
#	src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs
#	src/Umbraco.Tests.Integration/Packaging/CreatedPackagesRepositoryTests.cs
#	src/Umbraco.Tests.Integration/Services/CachedDataTypeServiceTests.cs
#	src/Umbraco.Tests.Integration/Services/DataTypeServiceTests.cs
#	src/Umbraco.Tests.Integration/Services/MacroServiceTests.cs
#	src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
#	src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/LocalizedTextServiceTests.cs
This commit is contained in:
Bjarke Berg
2020-10-06 18:47:12 +02:00
39 changed files with 800 additions and 903 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.Logging;
@@ -15,6 +16,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;
@@ -51,6 +53,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>
@@ -101,5 +107,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

@@ -50,7 +50,6 @@ namespace Umbraco.Tests.Integration.Testing
[NonParallelizable]
public abstract class UmbracoIntegrationTest
{
public static LightInjectContainer CreateUmbracoContainer(out UmbracoServiceProviderFactory serviceProviderFactory)
{
var container = UmbracoServiceProviderFactory.CreateServiceContainer();
@@ -82,6 +81,8 @@ namespace Umbraco.Tests.Integration.Testing
{
foreach (var a in _testTeardown) a();
_testTeardown = null;
FirstTestInFixture = false;
FirstTestInSession = false;
}
[SetUp]
@@ -278,7 +279,7 @@ namespace Umbraco.Tests.Integration.Testing
Services.GetRequiredService<IBackofficeSecurityFactory>().EnsureBackofficeSecurity();
Services.GetRequiredService<IUmbracoContextFactory>().EnsureUmbracoContext();
// get the currently set ptions
// get the currently set options
var testOptions = TestOptionAttributeBase.GetTestOptions<UmbracoTestAttribute>();
if (testOptions.Boot)
{
@@ -399,12 +400,26 @@ namespace Umbraco.Tests.Integration.Testing
break;
case UmbracoTestOptions.Database.NewSchemaPerFixture:
// Only attach schema once per fixture
// Doing it more than once will block the process since the old db hasn't been detached
// and it would be the same as NewSchemaPerTest even if it didn't block
if (FirstTestInFixture)
{
// New DB + Schema
var newSchemaFixtureDbId = db.AttachSchema();
// New DB + Schema
var newSchemaFixtureDbId = db.AttachSchema();
// Add teardown callback
OnFixtureTearDown(() => db.Detach(newSchemaFixtureDbId));
}
// Add teardown callback
OnFixtureTearDown(() => db.Detach(newSchemaFixtureDbId));
// We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings
if (!databaseFactory.Configured)
{
databaseFactory.Configure(db.ConnectionString, Constants.DatabaseProviders.SqlServer);
}
// re-run the runtime level check
runtimeState.DetermineRuntimeLevel();
break;
case UmbracoTestOptions.Database.NewEmptyPerFixture:
@@ -474,5 +489,9 @@ namespace Umbraco.Tests.Integration.Testing
protected UserGroupBuilder UserGroupBuilder = new UserGroupBuilder();
#endregion
protected static bool FirstTestInSession = true;
protected bool FirstTestInFixture = true;
}
}