From edd457c24b8d25b858702029476695d91fd7befd Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Mon, 31 Aug 2020 11:31:56 +0200 Subject: [PATCH] Force Examine to run in sync for integration tests --- src/Umbraco.Core/Composing/TypeFinder.cs | 1 + .../UmbracoContentIndex.cs | 6 +++++- .../Controllers/ContentControllerTests.cs | 2 +- .../UmbracoTestServerTestBase.cs | 20 ++++++++++++++++++- .../Umbraco.Tests.Integration.csproj | 1 + 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/Composing/TypeFinder.cs b/src/Umbraco.Core/Composing/TypeFinder.cs index 13c5e063be..3427c55731 100644 --- a/src/Umbraco.Core/Composing/TypeFinder.cs +++ b/src/Umbraco.Core/Composing/TypeFinder.cs @@ -156,6 +156,7 @@ namespace Umbraco.Core.Composing "MiniProfiler.", "Owin,", "SQLite", + "ReSharperTestRunner32" // used by resharper testrunner }; /// diff --git a/src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs b/src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs index dc2a5570a6..a4fa47009f 100644 --- a/src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs +++ b/src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs @@ -19,9 +19,13 @@ namespace Umbraco.Examine /// /// An indexer for Umbraco content and media /// - public class UmbracoContentIndex : UmbracoExamineIndex, IUmbracoContentIndex + public class UmbracoContentIndex : UmbracoExamineIndex, IUmbracoContentIndex, IDisposable { + void IDisposable.Dispose() + { + base.Dispose(); + } protected ILocalizationService LanguageService { get; } #region Constructors diff --git a/src/Umbraco.Tests.Integration/TestServerTest/Controllers/ContentControllerTests.cs b/src/Umbraco.Tests.Integration/TestServerTest/Controllers/ContentControllerTests.cs index a9a272ac59..57be7e2e05 100644 --- a/src/Umbraco.Tests.Integration/TestServerTest/Controllers/ContentControllerTests.cs +++ b/src/Umbraco.Tests.Integration/TestServerTest/Controllers/ContentControllerTests.cs @@ -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 { diff --git a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs index b666cc40f2..c5f413e24f 100644 --- a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs +++ b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs @@ -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(); + + ExecuteExamineIndexOperationsInSync(); + } + + private void ExecuteExamineIndexOperationsInSync() + { + var examineManager = Factory.Services.GetRequiredService(); + + foreach (var index in examineManager.Indexes) + { + if (index is UmbracoExamineIndex umbracoExamineIndex) + { + umbracoExamineIndex.ProcessNonAsync(); + } + } } /// diff --git a/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj b/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj index ba986ebd86..072f15bcd1 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj +++ b/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj @@ -14,6 +14,7 @@ +