Force Examine to run in sync for integration tests

This commit is contained in:
Bjarke Berg
2020-08-31 11:31:56 +02:00
parent 30b1d52e67
commit edd457c24b
5 changed files with 27 additions and 3 deletions

View File

@@ -156,6 +156,7 @@ namespace Umbraco.Core.Composing
"MiniProfiler.",
"Owin,",
"SQLite",
"ReSharperTestRunner32" // used by resharper testrunner
};
/// <summary>

View File

@@ -19,9 +19,13 @@ namespace Umbraco.Examine
/// <summary>
/// An indexer for Umbraco content and media
/// </summary>
public class UmbracoContentIndex : UmbracoExamineIndex, IUmbracoContentIndex
public class UmbracoContentIndex : UmbracoExamineIndex, IUmbracoContentIndex, IDisposable
{
void IDisposable.Dispose()
{
base.Dispose();
}
protected ILocalizationService LanguageService { get; }
#region Constructors

View File

@@ -18,7 +18,7 @@ using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.Tests.Integration.TestServerTest.Controllers
{
[TestFixture]
[Explicit("Need to figure out whats wrong with these tests when executed all in one run.")]
//[Explicit("Need to figure out whats wrong with these tests when executed all in one run.")]
public class ContentControllerTests : UmbracoTestServerTestBase
{

View File

@@ -3,18 +3,20 @@ using System;
using System.Linq.Expressions;
using System.Net.Http;
using System.Reflection;
using Examine;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using Umbraco.Composing;
using Umbraco.Core.Scoping;
using Umbraco.Examine;
using Umbraco.Extensions;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
using Umbraco.Web;
using Umbraco.Web.Common.Controllers;
using Umbraco.Web.Editors;
namespace Umbraco.Tests.Integration.TestServerTest
@@ -23,6 +25,7 @@ namespace Umbraco.Tests.Integration.TestServerTest
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, Logger = UmbracoTestOptions.Logger.Console, Boot = false)]
public abstract class UmbracoTestServerTestBase : UmbracoIntegrationTest
{
[SetUp]
public void SetUp()
{
@@ -31,6 +34,21 @@ namespace Umbraco.Tests.Integration.TestServerTest
AllowAutoRedirect = false
});
LinkGenerator = Factory.Services.GetRequiredService<LinkGenerator>();
ExecuteExamineIndexOperationsInSync();
}
private void ExecuteExamineIndexOperationsInSync()
{
var examineManager = Factory.Services.GetRequiredService<IExamineManager>();
foreach (var index in examineManager.Indexes)
{
if (index is UmbracoExamineIndex umbracoExamineIndex)
{
umbracoExamineIndex.ProcessNonAsync();
}
}
}
/// <summary>

View File

@@ -14,6 +14,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Examine.Lucene" Version="2.0.0-alpha.20200128.15" />
<PackageReference Include="LightInject.Microsoft.DependencyInjection" Version="3.3.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.4" />