2020-04-03 13:16:01 +11:00
|
|
|
|
using Moq;
|
|
|
|
|
|
using Umbraco.Core;
|
|
|
|
|
|
using Umbraco.Core.Composing;
|
2020-09-02 18:10:29 +10:00
|
|
|
|
using Umbraco.Core.Configuration;
|
|
|
|
|
|
using Umbraco.Core.Hosting;
|
|
|
|
|
|
using Umbraco.Core.Logging;
|
|
|
|
|
|
using Umbraco.Core.Services;
|
2020-04-03 13:16:01 +11:00
|
|
|
|
using Umbraco.Core.WebAssets;
|
2020-09-02 18:10:29 +10:00
|
|
|
|
using Umbraco.Examine;
|
2020-09-04 00:27:43 +10:00
|
|
|
|
using Umbraco.Web.Compose;
|
2020-09-02 18:10:29 +10:00
|
|
|
|
using Umbraco.Web.PublishedCache.NuCache;
|
|
|
|
|
|
using Umbraco.Web.Scheduling;
|
|
|
|
|
|
using Umbraco.Web.Search;
|
2020-04-03 13:16:01 +11:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Tests.Integration.Testing
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This is used to replace certain services that are normally registered from our Core / Infrastructure that
|
|
|
|
|
|
/// we do not want active within integration tests
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// This is a IUserComposer so that it runs after all core composers
|
|
|
|
|
|
/// </remarks>
|
|
|
|
|
|
[RuntimeLevel(MinLevel = RuntimeLevel.Boot)]
|
2020-09-02 18:10:29 +10:00
|
|
|
|
public class IntegrationTestComposer : ComponentComposer<IntegrationTestComponent>
|
2020-04-03 13:16:01 +11:00
|
|
|
|
{
|
2020-09-02 18:10:29 +10:00
|
|
|
|
public override void Compose(Composition composition)
|
2020-04-03 13:16:01 +11:00
|
|
|
|
{
|
2020-09-02 18:10:29 +10:00
|
|
|
|
base.Compose(composition);
|
|
|
|
|
|
|
|
|
|
|
|
composition.Components().Remove<SchedulerComponent>();
|
2020-09-04 00:27:43 +10:00
|
|
|
|
composition.Components().Remove<DatabaseServerRegistrarAndMessengerComponent>();
|
2020-09-02 18:10:29 +10:00
|
|
|
|
composition.RegisterUnique<BackgroundIndexRebuilder, TestBackgroundIndexRebuilder>();
|
2020-04-03 13:16:01 +11:00
|
|
|
|
composition.RegisterUnique<IRuntimeMinifier>(factory => Mock.Of<IRuntimeMinifier>());
|
2020-09-02 18:10:29 +10:00
|
|
|
|
|
|
|
|
|
|
// we don't want persisted nucache files in tests
|
|
|
|
|
|
composition.Register(factory => new PublishedSnapshotServiceOptions { IgnoreLocalDb = true });
|
|
|
|
|
|
|
|
|
|
|
|
// ensure all lucene indexes are using RAM directory (no file system)
|
|
|
|
|
|
composition.RegisterUnique<ILuceneDirectoryFactory, LuceneRAMDirectoryFactory>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// replace the default so there is no background index rebuilder
|
|
|
|
|
|
private class TestBackgroundIndexRebuilder : BackgroundIndexRebuilder
|
|
|
|
|
|
{
|
|
|
|
|
|
public TestBackgroundIndexRebuilder(IMainDom mainDom, IProfilingLogger logger, IApplicationShutdownRegistry hostingEnvironment, IndexRebuilder indexRebuilder)
|
|
|
|
|
|
: base(mainDom, logger, hostingEnvironment, indexRebuilder)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void RebuildIndexes(bool onlyEmptyIndexes, int waitMilliseconds = 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
// noop
|
|
|
|
|
|
}
|
2020-04-03 13:16:01 +11:00
|
|
|
|
}
|
2020-09-02 18:10:29 +10:00
|
|
|
|
|
2020-04-03 13:16:01 +11:00
|
|
|
|
}
|
|
|
|
|
|
}
|