2020-12-23 11:35:49 +01:00
|
|
|
// Copyright (c) Umbraco.
|
|
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
|
|
|
|
using Examine;
|
2020-09-02 18:10:29 +10:00
|
|
|
using Examine.LuceneEngine.Providers;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Composing;
|
2020-09-02 18:10:29 +10:00
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
namespace Umbraco.Cms.Tests.Integration.Testing
|
2020-09-02 18:10:29 +10:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A component to customize some services to work nicely with integration tests
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class IntegrationTestComponent : IComponent
|
|
|
|
|
{
|
|
|
|
|
private readonly IExamineManager _examineManager;
|
|
|
|
|
|
2020-12-23 11:35:49 +01:00
|
|
|
public IntegrationTestComponent(IExamineManager examineManager) => _examineManager = examineManager;
|
2020-09-02 18:10:29 +10:00
|
|
|
|
2020-12-23 11:35:49 +01:00
|
|
|
public void Initialize() => ConfigureExamineIndexes();
|
2020-09-02 18:10:29 +10:00
|
|
|
|
|
|
|
|
public void Terminate()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Configure all indexes to run sync (non-backbround threads) and to use RAMDirectory
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void ConfigureExamineIndexes()
|
|
|
|
|
{
|
2020-12-23 11:35:49 +01:00
|
|
|
foreach (IIndex index in _examineManager.Indexes)
|
2020-09-02 18:10:29 +10:00
|
|
|
{
|
|
|
|
|
if (index is LuceneIndex luceneIndex)
|
|
|
|
|
{
|
|
|
|
|
luceneIndex.ProcessNonAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|