Drop ref to Web.UI from integration tests (#11413)

* Remove reference to Web.UI, Fix test server content root

* Cleanup test databases in parallel
This commit is contained in:
Paul Johnson
2021-10-19 10:09:48 +01:00
committed by GitHub
parent 00133e880d
commit 37a429017e
4 changed files with 17 additions and 14 deletions

View File

@@ -4,6 +4,7 @@
using System;
using System.Linq.Expressions;
using System.Net.Http;
using System.Reflection;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
@@ -24,7 +25,6 @@ using Umbraco.Cms.Tests.Integration.DependencyInjection;
using Umbraco.Cms.Tests.Integration.Testing;
using Umbraco.Cms.Web.BackOffice.Controllers;
using Umbraco.Cms.Web.Common.Controllers;
using Umbraco.Cms.Web.UI;
using Umbraco.Cms.Web.Website.Controllers;
using Umbraco.Extensions;
@@ -52,17 +52,22 @@ namespace Umbraco.Cms.Tests.Integration.TestServerTest
*
* See https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests
*/
var factory = new UmbracoWebApplicationFactory<Startup>(CreateHostBuilder, BeforeHostStart);
var factory = new UmbracoWebApplicationFactory<UmbracoTestServerTestBase>(CreateHostBuilder, BeforeHostStart);
// additional host configuration for web server integration tests
Factory = factory.WithWebHostBuilder(builder =>
{
// Otherwise inferred as $(SolutionDir)/Umbraco.Tests.Integration (note lack of src/tests)
builder.UseContentRoot(Assembly.GetExecutingAssembly().GetRootDirectorySafe());
// Executes after the standard ConfigureServices method
builder.ConfigureTestServices(services =>
// Add a test auth scheme with a test auth handler to authn and assign the user
services.AddAuthentication(TestAuthHandler.TestAuthenticationScheme)
.AddScheme<AuthenticationSchemeOptions, TestAuthHandler>(TestAuthHandler.TestAuthenticationScheme, options => { })));
.AddScheme<AuthenticationSchemeOptions, TestAuthHandler>(TestAuthHandler.TestAuthenticationScheme, options => { }));
});
Client = Factory.CreateClient(new WebApplicationFactoryClientOptions
{
@@ -141,7 +146,7 @@ namespace Umbraco.Cms.Tests.Integration.TestServerTest
protected LinkGenerator LinkGenerator { get; private set; }
protected WebApplicationFactory<Startup> Factory { get; private set; }
protected WebApplicationFactory<UmbracoTestServerTestBase> Factory { get; private set; }
public override void ConfigureServices(IServiceCollection services)
{

View File

@@ -6,6 +6,7 @@ using System.Collections.Concurrent;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Infrastructure.Persistence;
@@ -118,13 +119,13 @@ namespace Umbraco.Cms.Tests.Integration.Testing
string filename = Path.Combine(s_filesPath, DatabaseName).ToUpper();
foreach (string database in s_localDbInstance.GetDatabases())
Parallel.ForEach(s_localDbInstance.GetDatabases(), instance =>
{
if (database.StartsWith(filename))
if (instance.StartsWith(filename))
{
s_localDbInstance.DropDatabase(database);
s_localDbInstance.DropDatabase(instance);
}
}
});
_localDb.StopInstance(InstanceName);

View File

@@ -6,6 +6,7 @@ using System.Collections.Concurrent;
using System.Data.SqlClient;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Infrastructure.Persistence;
@@ -118,10 +119,7 @@ namespace Umbraco.Cms.Tests.Integration.Testing
{
}
foreach (TestDbMeta testDatabase in _testDatabases)
{
Drop(testDatabase);
}
Parallel.ForEach(_testDatabases, Drop);
}
}
}

View File

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
@@ -99,7 +99,6 @@
<ProjectReference Include="..\..\src\Umbraco.PublishedCache.NuCache\Umbraco.PublishedCache.NuCache.csproj" />
<ProjectReference Include="..\Umbraco.Tests.Common\Umbraco.Tests.Common.csproj" />
<ProjectReference Include="..\..\src\Umbraco.Web.BackOffice\Umbraco.Web.BackOffice.csproj" />
<ProjectReference Include="..\..\src\Umbraco.Web.UI\Umbraco.Web.UI.csproj" />
<ProjectReference Include="..\..\src\Umbraco.Web.Website\Umbraco.Web.Website.csproj" />
</ItemGroup>