Skip to content

Commit 37a4290

Browse files
author
Paul Johnson
authored
Drop ref to Web.UI from integration tests (#11413)
* Remove reference to Web.UI, Fix test server content root * Cleanup test databases in parallel
1 parent 00133e8 commit 37a4290

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

tests/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Linq.Expressions;
66
using System.Net.Http;
7+
using System.Reflection;
78
using Microsoft.AspNetCore.Authentication;
89
using Microsoft.AspNetCore.Builder;
910
using Microsoft.AspNetCore.Hosting;
@@ -24,7 +25,6 @@
2425
using Umbraco.Cms.Tests.Integration.Testing;
2526
using Umbraco.Cms.Web.BackOffice.Controllers;
2627
using Umbraco.Cms.Web.Common.Controllers;
27-
using Umbraco.Cms.Web.UI;
2828
using Umbraco.Cms.Web.Website.Controllers;
2929
using Umbraco.Extensions;
3030

@@ -52,17 +52,22 @@ public override void Setup()
5252
*
5353
* See https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests
5454
*/
55-
var factory = new UmbracoWebApplicationFactory<Startup>(CreateHostBuilder, BeforeHostStart);
55+
var factory = new UmbracoWebApplicationFactory<UmbracoTestServerTestBase>(CreateHostBuilder, BeforeHostStart);
5656

5757
// additional host configuration for web server integration tests
5858
Factory = factory.WithWebHostBuilder(builder =>
59+
{
60+
// Otherwise inferred as $(SolutionDir)/Umbraco.Tests.Integration (note lack of src/tests)
61+
builder.UseContentRoot(Assembly.GetExecutingAssembly().GetRootDirectorySafe());
5962

6063
// Executes after the standard ConfigureServices method
6164
builder.ConfigureTestServices(services =>
6265

6366
// Add a test auth scheme with a test auth handler to authn and assign the user
6467
services.AddAuthentication(TestAuthHandler.TestAuthenticationScheme)
65-
.AddScheme<AuthenticationSchemeOptions, TestAuthHandler>(TestAuthHandler.TestAuthenticationScheme, options => { })));
68+
.AddScheme<AuthenticationSchemeOptions, TestAuthHandler>(TestAuthHandler.TestAuthenticationScheme, options => { }));
69+
});
70+
6671

6772
Client = Factory.CreateClient(new WebApplicationFactoryClientOptions
6873
{
@@ -141,7 +146,7 @@ protected string PrepareUrl(string url)
141146

142147
protected LinkGenerator LinkGenerator { get; private set; }
143148

144-
protected WebApplicationFactory<Startup> Factory { get; private set; }
149+
protected WebApplicationFactory<UmbracoTestServerTestBase> Factory { get; private set; }
145150

146151
public override void ConfigureServices(IServiceCollection services)
147152
{

tests/Umbraco.Tests.Integration/Testing/LocalDbTestDatabase.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.IO;
77
using System.Linq;
88
using System.Threading;
9+
using System.Threading.Tasks;
910
using Microsoft.Extensions.Logging;
1011
using Umbraco.Cms.Infrastructure.Persistence;
1112

@@ -118,13 +119,13 @@ public void Finish()
118119

119120
string filename = Path.Combine(s_filesPath, DatabaseName).ToUpper();
120121

121-
foreach (string database in s_localDbInstance.GetDatabases())
122+
Parallel.ForEach(s_localDbInstance.GetDatabases(), instance =>
122123
{
123-
if (database.StartsWith(filename))
124+
if (instance.StartsWith(filename))
124125
{
125-
s_localDbInstance.DropDatabase(database);
126+
s_localDbInstance.DropDatabase(instance);
126127
}
127-
}
128+
});
128129

129130
_localDb.StopInstance(InstanceName);
130131

tests/Umbraco.Tests.Integration/Testing/SqlDeveloperTestDatabase.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Data.SqlClient;
77
using System.Linq;
88
using System.Threading;
9+
using System.Threading.Tasks;
910
using Microsoft.Extensions.Logging;
1011
using Umbraco.Cms.Infrastructure.Persistence;
1112

@@ -118,10 +119,7 @@ public void Finish()
118119
{
119120
}
120121

121-
foreach (TestDbMeta testDatabase in _testDatabases)
122-
{
123-
Drop(testDatabase);
124-
}
122+
Parallel.ForEach(_testDatabases, Drop);
125123
}
126124
}
127125
}

tests/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
@@ -99,7 +99,6 @@
9999
<ProjectReference Include="..\..\src\Umbraco.PublishedCache.NuCache\Umbraco.PublishedCache.NuCache.csproj" />
100100
<ProjectReference Include="..\Umbraco.Tests.Common\Umbraco.Tests.Common.csproj" />
101101
<ProjectReference Include="..\..\src\Umbraco.Web.BackOffice\Umbraco.Web.BackOffice.csproj" />
102-
<ProjectReference Include="..\..\src\Umbraco.Web.UI\Umbraco.Web.UI.csproj" />
103102
<ProjectReference Include="..\..\src\Umbraco.Web.Website\Umbraco.Web.Website.csproj" />
104103
</ItemGroup>
105104

0 commit comments

Comments
 (0)