Specified hostingenvironment and databaseproviders after unit tests not picking up Umbraco.Core namespaces
Migrated into integrations project configurations, as files are being read
This commit is contained in:
@@ -4,7 +4,6 @@ using System.Runtime.InteropServices;
|
||||
|
||||
// Umbraco Cms
|
||||
[assembly: InternalsVisibleTo("Umbraco.Tests")]
|
||||
[assembly: InternalsVisibleTo("Umbraco.Tests.UnitTests")]
|
||||
[assembly: InternalsVisibleTo("Umbraco.Tests.Common")]
|
||||
[assembly: InternalsVisibleTo("Umbraco.Tests.Benchmarks")]
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Umbraco.Tests.Common
|
||||
/// </summary>
|
||||
/// <param name="relativePath"></param>
|
||||
/// <returns></returns>
|
||||
public string MapPathForTestFiles(string relativePath)
|
||||
public virtual string MapPathForTestFiles(string relativePath)
|
||||
{
|
||||
if (!relativePath.StartsWith("~/"))
|
||||
throw new ArgumentException("relativePath must start with '~/'", nameof(relativePath));
|
||||
|
||||
@@ -5,9 +5,7 @@ using System.IO;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Configuration.Models;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
@@ -63,7 +61,7 @@ namespace Umbraco.Tests.Integration.Extensions
|
||||
var dbFactory = app.ApplicationServices.GetRequiredService<IUmbracoDatabaseFactory>();
|
||||
if (!dbFactory.Configured)
|
||||
{
|
||||
dbFactory.Configure(db.ConnectionString, Umbraco.Core.Constants.DatabaseProviders.SqlServer);
|
||||
dbFactory.Configure(db.ConnectionString, Constants.DatabaseProviders.SqlServer);
|
||||
}
|
||||
|
||||
// In the case that we've initialized the schema, it means that we are installed so we'll want to ensure that
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Tests.Integration.Implementations;
|
||||
|
||||
namespace Umbraco.Tests.Integration.Extensions
|
||||
|
||||
@@ -17,8 +17,6 @@ using Umbraco.Net;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Runtime;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Web.BackOffice;
|
||||
using Umbraco.Web.BackOffice.AspNetCore;
|
||||
using Umbraco.Web.Common.AspNetCore;
|
||||
using IHostingEnvironment = Umbraco.Core.Hosting.IHostingEnvironment;
|
||||
|
||||
@@ -43,7 +41,8 @@ namespace Umbraco.Tests.Integration.Implementations
|
||||
|
||||
var hostEnvironment = new Mock<IWebHostEnvironment>();
|
||||
hostEnvironment.Setup(x => x.ApplicationName).Returns("UmbracoIntegrationTests");
|
||||
hostEnvironment.Setup(x => x.ContentRootPath).Returns(() => Assembly.GetExecutingAssembly().GetRootDirectorySafe());
|
||||
hostEnvironment.Setup(x => x.ContentRootPath)
|
||||
.Returns(() => Assembly.GetExecutingAssembly().GetRootDirectorySafe());
|
||||
hostEnvironment.Setup(x => x.WebRootPath).Returns(() => WorkingDirectory);
|
||||
_hostEnvironment = hostEnvironment.Object;
|
||||
|
||||
@@ -79,9 +78,11 @@ namespace Umbraco.Tests.Integration.Implementations
|
||||
}
|
||||
}
|
||||
|
||||
public IUmbracoBootPermissionChecker UmbracoBootPermissionChecker { get; } = new TestUmbracoBootPermissionChecker();
|
||||
public IUmbracoBootPermissionChecker UmbracoBootPermissionChecker { get; } =
|
||||
new TestUmbracoBootPermissionChecker();
|
||||
|
||||
public AppCaches AppCaches { get; } = new AppCaches(NoAppCache.Instance, NoAppCache.Instance, new IsolatedCaches(type => NoAppCache.Instance));
|
||||
public AppCaches AppCaches { get; } = new AppCaches(NoAppCache.Instance, NoAppCache.Instance,
|
||||
new IsolatedCaches(type => NoAppCache.Instance));
|
||||
|
||||
public IProfilingLogger Logger { get; private set; }
|
||||
|
||||
@@ -91,7 +92,8 @@ namespace Umbraco.Tests.Integration.Implementations
|
||||
|
||||
public IWebHostEnvironment GetWebHostEnvironment() => _hostEnvironment;
|
||||
|
||||
public override IDbProviderFactoryCreator DbProviderFactoryCreator => new SqlServerDbProviderFactoryCreator(Constants.DbProviderNames.SqlServer, DbProviderFactories.GetFactory);
|
||||
public override IDbProviderFactoryCreator DbProviderFactoryCreator =>
|
||||
new SqlServerDbProviderFactoryCreator(Constants.DbProviderNames.SqlServer, DbProviderFactories.GetFactory);
|
||||
|
||||
public override IBulkSqlInsertProvider BulkSqlInsertProvider => new SqlServerBulkSqlInsertProvider();
|
||||
|
||||
@@ -100,7 +102,8 @@ namespace Umbraco.Tests.Integration.Implementations
|
||||
public override IBackOfficeInfo GetBackOfficeInfo()
|
||||
{
|
||||
if (_backOfficeInfo == null)
|
||||
_backOfficeInfo = new AspNetCoreBackOfficeInfo(SettingsForTests.GetDefaultGlobalSettings(GetUmbracoVersion()));
|
||||
_backOfficeInfo =
|
||||
new AspNetCoreBackOfficeInfo(SettingsForTests.GetDefaultGlobalSettings(GetUmbracoVersion()));
|
||||
return _backOfficeInfo;
|
||||
}
|
||||
|
||||
@@ -113,5 +116,22 @@ namespace Umbraco.Tests.Integration.Implementations
|
||||
|
||||
public override IIpResolver GetIpResolver() => _ipResolver;
|
||||
|
||||
/// <summary>
|
||||
/// Some test files are copied to the /bin (/bin/debug) on build, this is a utility to return their physical path based on a virtual path name
|
||||
/// </summary>
|
||||
/// <param name="relativePath"></param>
|
||||
/// <returns></returns>
|
||||
public override string MapPathForTestFiles(string relativePath)
|
||||
{
|
||||
if (!relativePath.StartsWith("~/"))
|
||||
throw new ArgumentException("relativePath must start with '~/'", nameof(relativePath));
|
||||
|
||||
var codeBase = typeof(TestHelperBase).Assembly.CodeBase;
|
||||
var uri = new Uri(codeBase);
|
||||
var path = uri.LocalPath;
|
||||
var bin = Path.GetDirectoryName(path);
|
||||
|
||||
return relativePath.Replace("~/", bin + "/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Web.Common.AspNetCore;
|
||||
using IHostingEnvironment = Umbraco.Core.Hosting.IHostingEnvironment;
|
||||
|
||||
namespace Umbraco.Tests.Integration.Implementations
|
||||
{
|
||||
|
||||
public class TestHostingEnvironment : AspNetCoreHostingEnvironment, Umbraco.Core.Hosting.IHostingEnvironment
|
||||
public class TestHostingEnvironment : AspNetCoreHostingEnvironment, IHostingEnvironment
|
||||
{
|
||||
public TestHostingEnvironment(IHostingSettings hostingSettings, IWebHostEnvironment webHostEnvironment)
|
||||
: base(hostingSettings, webHostEnvironment)
|
||||
@@ -19,6 +19,6 @@ namespace Umbraco.Tests.Integration.Implementations
|
||||
/// <remarks>
|
||||
/// This is specifically used by IOHelper and we want this to return false so that the root path is manually calcualted which is what we want for tests.
|
||||
/// </remarks>
|
||||
bool Umbraco.Core.Hosting.IHostingEnvironment.IsHosted { get; } = false;
|
||||
bool IHostingEnvironment.IsHosted { get; } = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Migrations.Install;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Web.Common.RuntimeMinification;
|
||||
|
||||
namespace Umbraco.Tests.Integration.Testing
|
||||
{
|
||||
@@ -122,7 +121,7 @@ namespace Umbraco.Tests.Integration.Testing
|
||||
}
|
||||
else
|
||||
{
|
||||
_dbFactory.Configure(conn.ConnectionString, Umbraco.Core.Constants.DatabaseProviders.SqlServer);
|
||||
_dbFactory.Configure(conn.ConnectionString, Constants.DatabaseProviders.SqlServer);
|
||||
|
||||
using var database = (UmbracoDatabase)_dbFactory.CreateDatabase();
|
||||
// track each db command ran as part of creating the database so we can replay these
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Configuration.UmbracoSettings
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings
|
||||
{
|
||||
[TestFixture]
|
||||
public class ContentElementDefaultTests : ContentElementTests
|
||||
+1
-1
@@ -6,7 +6,7 @@ using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Macros;
|
||||
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Configuration.UmbracoSettings
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings
|
||||
{
|
||||
[TestFixture]
|
||||
public class ContentElementTests : UmbracoSettingsTests
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Configuration.UmbracoSettings
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings
|
||||
{
|
||||
[TestFixture]
|
||||
public class LoggingElementDefaultTests : LoggingElementTests
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Configuration.UmbracoSettings
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings
|
||||
{
|
||||
[TestFixture]
|
||||
public class LoggingElementTests : UmbracoSettingsTests
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Configuration.UmbracoSettings
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings
|
||||
{
|
||||
[TestFixture]
|
||||
public class RequestHandlerElementDefaultTests : RequestHandlerElementTests
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Configuration.UmbracoSettings
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings
|
||||
{
|
||||
[TestFixture]
|
||||
public class RequestHandlerElementTests : UmbracoSettingsTests
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Configuration.UmbracoSettings
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings
|
||||
{
|
||||
[TestFixture]
|
||||
public class SecurityElementDefaultTests : SecurityElementTests
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Configuration.UmbracoSettings
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings
|
||||
{
|
||||
[TestFixture]
|
||||
public class SecurityElementTests : UmbracoSettingsTests
|
||||
+4
-3
@@ -4,9 +4,9 @@ using System.IO;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Helpers;
|
||||
using Umbraco.Tests.Integration.Implementations;
|
||||
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Configuration.UmbracoSettings
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings
|
||||
{
|
||||
public abstract class UmbracoSettingsTests
|
||||
{
|
||||
@@ -15,7 +15,8 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Configuration.UmbracoSettings
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
var config = new FileInfo(TestHelper.MapPathForTestFiles("~/Umbraco.Configuration/UmbracoSettings/web.config"));
|
||||
var testHelper = new TestHelper();
|
||||
var config = new FileInfo(testHelper.MapPathForTestFiles("~/Umbraco.Configuration/Configurations/web.config"));
|
||||
|
||||
var fileMap = new ExeConfigurationFileMap() { ExeConfigFilename = config.FullName };
|
||||
var configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Configuration.UmbracoSettings
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings
|
||||
{
|
||||
[TestFixture]
|
||||
public class WebRoutingElementDefaultTests : WebRoutingElementTests
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Configuration.UmbracoSettings
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings
|
||||
{
|
||||
[TestFixture]
|
||||
public class WebRoutingElementTests : UmbracoSettingsTests
|
||||
@@ -32,4 +32,16 @@
|
||||
<ProjectReference Include="..\Umbraco.Web.BackOffice\Umbraco.Web.BackOffice.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Umbraco.Configuration\Configurations\umbracoSettings.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Umbraco.Configuration\Configurations\umbracoSettings.minimal.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Umbraco.Configuration\Configurations\web.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user