Gets CoreRuntime loading/booting in integration project
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using System.Data.Common;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Tests.Integration.Implementations
|
||||
{
|
||||
public class TestDbProviderFactoryCreator : IDbProviderFactoryCreator
|
||||
{
|
||||
public IBulkSqlInsertProvider CreateBulkSqlInsertProvider(string providerName)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public void CreateDatabase()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public DbProviderFactory CreateFactory()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public DbProviderFactory CreateFactory(string providerName)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public ISqlSyntaxProvider GetSqlSyntaxProvider(string providerName)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
80
src/Umbraco.Tests.Integration/Implementations/TestHelper.cs
Normal file
80
src/Umbraco.Tests.Integration/Implementations/TestHelper.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Moq;
|
||||
using System.Net;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Diagnostics;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Runtime;
|
||||
using Umbraco.Net;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Web.BackOffice;
|
||||
using Umbraco.Web.BackOffice.AspNetCore;
|
||||
using IHostingEnvironment = Umbraco.Core.Hosting.IHostingEnvironment;
|
||||
|
||||
namespace Umbraco.Tests.Integration.Implementations
|
||||
{
|
||||
|
||||
public class TestHelper : TestHelperBase
|
||||
{
|
||||
private IBackOfficeInfo _backOfficeInfo;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IIpResolver _ipResolver;
|
||||
private readonly IWebHostEnvironment _hostEnvironment;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public TestHelper() : base(typeof(TestHelper).Assembly)
|
||||
{
|
||||
var httpContext = new DefaultHttpContext();
|
||||
httpContext.Connection.RemoteIpAddress = IPAddress.Parse("127.0.0.1");
|
||||
_httpContextAccessor = Mock.Of<IHttpContextAccessor>(x => x.HttpContext == httpContext);
|
||||
_ipResolver = new AspNetIpResolver(_httpContextAccessor);
|
||||
|
||||
_hostEnvironment = Mock.Of<IWebHostEnvironment>(x =>
|
||||
x.ApplicationName == "UmbracoIntegrationTests"
|
||||
&& x.ContentRootPath == CurrentAssemblyDirectory
|
||||
&& x.WebRootPath == CurrentAssemblyDirectory); // same folder for now?
|
||||
|
||||
_hostingEnvironment = new AspNetCoreHostingEnvironment(
|
||||
SettingsForTests.GetDefaultHostingSettings(),
|
||||
_hostEnvironment,
|
||||
_httpContextAccessor,
|
||||
Mock.Of<IHostApplicationLifetime>());
|
||||
|
||||
Logger = new ProfilingLogger(new ConsoleLogger(new MessageTemplates()), Profiler);
|
||||
}
|
||||
|
||||
public IUmbracoBootPermissionChecker UmbracoBootPermissionChecker { get; } = new TestUmbracoBootPermissionChecker();
|
||||
|
||||
public AppCaches AppCaches { get; } = new AppCaches(NoAppCache.Instance, NoAppCache.Instance, new IsolatedCaches(type => NoAppCache.Instance));
|
||||
|
||||
public IProfilingLogger Logger { get; private set; }
|
||||
|
||||
public IProfiler Profiler { get; } = new VoidProfiler();
|
||||
|
||||
public IHttpContextAccessor GetHttpContextAccessor() => _httpContextAccessor;
|
||||
|
||||
public IWebHostEnvironment GetWebHostEnvironment() => _hostEnvironment;
|
||||
|
||||
public override IDbProviderFactoryCreator DbProviderFactoryCreator => new TestDbProviderFactoryCreator();
|
||||
|
||||
public override IBulkSqlInsertProvider BulkSqlInsertProvider => new SqlServerBulkSqlInsertProvider();
|
||||
|
||||
public override IMarchal Marchal { get; } = new AspNetCoreMarchal();
|
||||
|
||||
public override IBackOfficeInfo GetBackOfficeInfo()
|
||||
{
|
||||
if (_backOfficeInfo == null)
|
||||
_backOfficeInfo = new AspNetCoreBackOfficeInfo(SettingsForTests.GetDefaultGlobalSettings(GetUmbracoVersion(), IOHelper));
|
||||
return _backOfficeInfo;
|
||||
}
|
||||
|
||||
public override IHostingEnvironment GetHostingEnvironment() => _hostingEnvironment;
|
||||
|
||||
public override IIpResolver GetIpResolver() => _ipResolver;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Core.Runtime;
|
||||
|
||||
namespace Umbraco.Tests.Integration.Implementations
|
||||
{
|
||||
public class TestUmbracoBootPermissionChecker : IUmbracoBootPermissionChecker
|
||||
{
|
||||
public void ThrowIfNotPermissions()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user