Files
Umbraco-CMS/tests/Umbraco.Tests.Common/Testing/TestHostingEnvironment.cs
Paul Johnson 551f523079 V10 - Reduce usage of temp AspNetCoreHostingEnvironment (#12270)
* Move MapPathWebRoot & MapPathContentRoot to extension methods.

* Set AspNetCoreHostingEnvironment ApplicationId without service provider.

* Drop some usages of TempHostingEnvironment

* Logging setup cleanup - AppDomainId has no value (it is always "1")

Creating new AppDomains isn't possible in .Net core.
Attempting to do so results in a platform exception.

A dotnet core process has a single AppDomain instance whose Id property
is always the integer 1.

* Setup logging without IHostingEnvironment

* Mark IUmbracoBuilder.BuilderHostingEnvironment obsolete
And remove internal usages.

* Typeloader no longer uses umbraco-types.list

* Added UmbracoHost - setup serilog two-stage init.

* Add ApplicationIdEnricher

* Defensive tweaks for those not using UmbracoHost

* Drop UmbracoHost static class

* Setup runtime logger without host builder extensions.

* Prevent RefreshingRazorViewEngine related explosions

* Filescoped namespaces for new classes.

* Apply suggestions from code review
2022-04-25 16:27:53 +02:00

36 lines
1.2 KiB
C#

// Copyright (c) Umbraco.
// See LICENSE for more details.
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Web.Common.AspNetCore;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Tests.Common.Testing
{
public class TestHostingEnvironment : AspNetCoreHostingEnvironment, IHostingEnvironment
{
public TestHostingEnvironment(
IOptionsMonitor<HostingSettings> hostingSettings,
IOptionsMonitor<WebRoutingSettings> webRoutingSettings,
IWebHostEnvironment webHostEnvironment)
: base(hostingSettings, webRoutingSettings, webHostEnvironment)
{
}
// override
string IHostingEnvironment.ApplicationId { get; } = "TestApplication";
/// <summary>
/// Gets a value indicating whether we are hosted.
/// </summary>
/// <remarks>
/// This is specifically used by IOHelper and we want this to return false so that the root path is manually
/// calculated which is what we want for tests.
/// </remarks>
bool IHostingEnvironment.IsHosted { get; } = false;
}
}