Merge branch 'netcore/netcore' into netcore/members-userstore

# Conflicts:
#	src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs
#	src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
#	src/Umbraco.Tests.UnitTests/AutoFixture/AutoMoqDataAttribute.cs
#	src/Umbraco.Web.BackOffice/Controllers/ContentControllerBase.cs
#	src/Umbraco.Web.BackOffice/Extensions/UmbracoBuilderExtensions.cs
This commit is contained in:
Emma Garland
2021-01-04 17:04:05 +00:00
835 changed files with 15121 additions and 14260 deletions

View File

@@ -1,8 +1,6 @@
using System;
using System.Linq.Expressions;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
@@ -11,20 +9,23 @@ using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.DependencyInjection;
using Umbraco.Extensions;
using Umbraco.Infrastructure.PublishedCache.DependencyInjection;
using Umbraco.Tests.Integration.DependencyInjection;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
using Umbraco.Web;
using Umbraco.Core.DependencyInjection;
using Umbraco.Web.Common.Controllers;
using Microsoft.Extensions.Hosting;
using Umbraco.Core.Cache;
using Umbraco.Core.Persistence;
using Umbraco.Core.Runtime;
using Umbraco.Web.BackOffice.Controllers;
using Umbraco.Web.BackOffice.DependencyInjection;
using Umbraco.Web.Common.Controllers;
using Umbraco.Web.Common.DependencyInjection;
using Umbraco.Web.Website.Controllers;
using Umbraco.Web.Website.DependencyInjection;
namespace Umbraco.Tests.Integration.TestServerTest
{
@@ -39,7 +40,7 @@ namespace Umbraco.Tests.Integration.TestServerTest
InMemoryConfiguration["Umbraco:CMS:Hosting:Debug"] = "true";
// create new WebApplicationFactory specifying 'this' as the IStartup instance
var factory = new UmbracoWebApplicationFactory<UmbracoTestServerTestBase>(CreateHostBuilder);
var factory = new UmbracoWebApplicationFactory<UmbracoTestServerTestBase>(CreateHostBuilder, BeforeHostStart);
// additional host configuration for web server integration tests
Factory = factory.WithWebHostBuilder(builder =>
@@ -75,11 +76,10 @@ namespace Umbraco.Tests.Integration.TestServerTest
// call startup
builder.Configure(app =>
{
UseTestLocalDb(app.ApplicationServices);
Services = app.ApplicationServices;
Configure(app);
});
}).UseEnvironment(Environments.Development);
}).UseEnvironment(Environments.Development);
return builder;
}
@@ -116,53 +116,58 @@ namespace Umbraco.Tests.Integration.TestServerTest
}
protected HttpClient Client { get; private set; }
protected LinkGenerator LinkGenerator { get; private set; }
protected WebApplicationFactory<UmbracoTestServerTestBase> Factory { get; private set; }
[TearDown]
public override void TearDown()
{
base.TearDown();
base.TerminateCoreRuntime();
Factory.Dispose();
}
#region IStartup
public override void ConfigureServices(IServiceCollection services)
{
var typeLoader = services.AddTypeLoader(GetType().Assembly, TestHelper.GetWebHostEnvironment(), TestHelper.GetHostingEnvironment(),
TestHelper.ConsoleLoggerFactory, AppCaches.NoCache, Configuration, TestHelper.Profiler);
services.AddTransient<TestUmbracoDatabaseFactoryProvider>();
var typeLoader = services.AddTypeLoader(
GetType().Assembly,
TestHelper.GetWebHostEnvironment(),
TestHelper.GetHostingEnvironment(),
TestHelper.ConsoleLoggerFactory,
AppCaches.NoCache,
Configuration,
TestHelper.Profiler);
var builder = new UmbracoBuilder(services, Configuration, typeLoader);
builder
.AddConfiguration()
.AddTestCore(TestHelper) // This is the important one!
.AddUmbracoCore()
.AddWebComponents()
.AddRuntimeMinifier()
.AddBackOffice()
.AddBackOfficeCore()
.AddBackOfficeAuthentication()
.AddBackOfficeIdentity()
.AddMembersIdentity()
.AddBackOfficeAuthorizationPolicies(TestAuthHandler.TestAuthenticationScheme)
.AddPreviewSupport()
//.WithMiniProfiler() // we don't want this running in tests
.AddMvcAndRazor(mvcBuilding: mvcBuilder =>
{
// Adds Umbraco.Web.BackOffice
mvcBuilder.AddApplicationPart(typeof(ContentController).Assembly);
// Adds Umbraco.Web.Common
mvcBuilder.AddApplicationPart(typeof(RenderController).Assembly);
// Adds Umbraco.Web.Website
mvcBuilder.AddApplicationPart(typeof(SurfaceController).Assembly);
})
.AddWebServer()
.AddWebsite()
.AddTestServices(TestHelper) // This is the important one!
.Build();
}
public override void Configure(IApplicationBuilder app)
{
app.UseUmbraco();
app.UseUmbracoBackOffice();
app.UseUmbracoWebsite();
}
#endregion
}
}