Restored Umbraco.Tests.Common
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.Models;
|
||||
|
||||
namespace Umbraco.Tests.Common.Builders
|
||||
{
|
||||
@@ -9,7 +9,7 @@ namespace Umbraco.Tests.Common.Builders
|
||||
}
|
||||
}
|
||||
|
||||
public class GlobalSettingsBuilder<TParent> : ChildBuilderBase<TParent, IGlobalSettings>
|
||||
public class GlobalSettingsBuilder<TParent> : ChildBuilderBase<TParent, GlobalSettings>
|
||||
{
|
||||
private string _configurationStatus;
|
||||
private string _databaseFactoryServerVersion;
|
||||
@@ -166,7 +166,7 @@ namespace Umbraco.Tests.Common.Builders
|
||||
return this;
|
||||
}
|
||||
|
||||
public override IGlobalSettings Build()
|
||||
public override GlobalSettings Build()
|
||||
{
|
||||
var configurationStatus = _configurationStatus ?? "9.0.0";
|
||||
var databaseFactoryServerVersion = _databaseFactoryServerVersion ?? null;
|
||||
@@ -175,8 +175,6 @@ namespace Umbraco.Tests.Common.Builders
|
||||
var hideTopLevelNodeFromPath = _hideTopLevelNodeFromPath ?? false;
|
||||
var installEmptyDatabase = _installEmptyDatabase ?? false;
|
||||
var installMissingDatabase = _installMissingDatabase ?? false;
|
||||
var isSmtpServerConfigured = _isSmtpServerConfigured ?? false;
|
||||
var path = _path ?? "/umbraco";
|
||||
var registerType = _registerType ?? null;
|
||||
var reservedPaths = _reservedPaths ?? "~/app_plugins/,~/install/,~/mini-profiler-resources/,";
|
||||
var reservedUrls = _reservedUrls ?? "~/config/splashes/noNodes.aspx,~/.well-known,";
|
||||
@@ -191,7 +189,7 @@ namespace Umbraco.Tests.Common.Builders
|
||||
var mainDomLock = _mainDomLock ?? string.Empty;
|
||||
var noNodesViewPath = _noNodesViewPath ?? "~/config/splashes/NoNodes.cshtml";
|
||||
|
||||
return new TestGlobalSettings
|
||||
return new GlobalSettings
|
||||
{
|
||||
ConfigurationStatus = configurationStatus,
|
||||
DatabaseFactoryServerVersion = databaseFactoryServerVersion,
|
||||
@@ -200,8 +198,6 @@ namespace Umbraco.Tests.Common.Builders
|
||||
HideTopLevelNodeFromPath = hideTopLevelNodeFromPath,
|
||||
InstallEmptyDatabase = installEmptyDatabase,
|
||||
InstallMissingDatabase = installMissingDatabase,
|
||||
IsSmtpServerConfigured = isSmtpServerConfigured,
|
||||
Path = path,
|
||||
RegisterType = registerType,
|
||||
ReservedPaths = reservedPaths,
|
||||
ReservedUrls = reservedUrls,
|
||||
@@ -212,36 +208,10 @@ namespace Umbraco.Tests.Common.Builders
|
||||
UmbracoScriptsPath = umbracoScriptsPath,
|
||||
VersionCheckPeriod = versionCheckPeriod,
|
||||
TimeOutInMinutes = timeOutInMinutes,
|
||||
SmtpSettings = smtpSettings,
|
||||
Smtp = smtpSettings,
|
||||
MainDomLock = mainDomLock,
|
||||
NoNodesViewPath = noNodesViewPath,
|
||||
};
|
||||
}
|
||||
|
||||
private class TestGlobalSettings : IGlobalSettings
|
||||
{
|
||||
public string ReservedUrls { get; set; }
|
||||
public string ReservedPaths { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string ConfigurationStatus { get; set; }
|
||||
public int TimeOutInMinutes { get; set; }
|
||||
public string DefaultUILanguage { get; set; }
|
||||
public bool HideTopLevelNodeFromPath { get; set; }
|
||||
public bool UseHttps { get; set; }
|
||||
public int VersionCheckPeriod { get; set; }
|
||||
public string UmbracoPath { get; set; }
|
||||
public string UmbracoCssPath { get; set; }
|
||||
public string UmbracoScriptsPath { get; set; }
|
||||
public string UmbracoMediaPath { get; set; }
|
||||
public bool IsSmtpServerConfigured { get; set; }
|
||||
public ISmtpSettings SmtpSettings { get; set; }
|
||||
public bool InstallMissingDatabase { get; set; }
|
||||
public bool InstallEmptyDatabase { get; set; }
|
||||
public bool DisableElectionForSingleServer { get; set; }
|
||||
public string RegisterType { get; set; }
|
||||
public string DatabaseFactoryServerVersion { get; set; }
|
||||
public string MainDomLock { get; set; }
|
||||
public string NoNodesViewPath { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Moq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Tests.Common.Builders.Interfaces;
|
||||
|
||||
@@ -58,6 +57,7 @@ namespace Umbraco.Tests.Common.Builders
|
||||
public override ILanguage Build()
|
||||
{
|
||||
var cultureInfo = _cultureInfo ?? CultureInfo.GetCultureInfo("en-US");
|
||||
var globalSettings = new GlobalSettingsBuilder().WithDefaultUiLanguage(cultureInfo.Name).Build();
|
||||
var key = _key ?? Guid.NewGuid();
|
||||
var createDate = _createDate ?? DateTime.Now;
|
||||
var updateDate = _updateDate ?? DateTime.Now;
|
||||
@@ -66,7 +66,7 @@ namespace Umbraco.Tests.Common.Builders
|
||||
var isDefault = _isDefault ?? false;
|
||||
var isMandatory = _isMandatory ?? false;
|
||||
|
||||
return new Language(Mock.Of<IGlobalSettings>(), cultureInfo.Name)
|
||||
return new Language(globalSettings, cultureInfo.Name)
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
CultureName = cultureInfo.EnglishName,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Net.Mail;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Configuration.Models;
|
||||
|
||||
namespace Umbraco.Tests.Common.Builders
|
||||
{
|
||||
@@ -12,7 +11,7 @@ namespace Umbraco.Tests.Common.Builders
|
||||
}
|
||||
|
||||
public class SmtpSettingsBuilder<TParent>
|
||||
: ChildBuilderBase<TParent, ISmtpSettings>
|
||||
: ChildBuilderBase<TParent, SmtpSettings>
|
||||
{
|
||||
private string _from;
|
||||
private string _host;
|
||||
@@ -68,7 +67,7 @@ namespace Umbraco.Tests.Common.Builders
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ISmtpSettings Build()
|
||||
public override SmtpSettings Build()
|
||||
{
|
||||
var from = _from ?? null;
|
||||
var host = _host ?? null;
|
||||
@@ -78,7 +77,7 @@ namespace Umbraco.Tests.Common.Builders
|
||||
var username = _username ?? null;
|
||||
var password = _password ?? null;
|
||||
|
||||
return new TestSmtpSettings()
|
||||
return new SmtpSettings()
|
||||
{
|
||||
From = from,
|
||||
Host = host,
|
||||
@@ -89,16 +88,5 @@ namespace Umbraco.Tests.Common.Builders
|
||||
Password = password,
|
||||
};
|
||||
}
|
||||
|
||||
private class TestSmtpSettings : ISmtpSettings
|
||||
{
|
||||
public string From { get; set; }
|
||||
public string Host { get; set; }
|
||||
public int Port { get; set; }
|
||||
public string PickupDirectoryLocation { get; set; }
|
||||
public SmtpDeliveryMethod DeliveryMethod { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ using Umbraco.Core.Serialization;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Tests.Common.Builders;
|
||||
|
||||
namespace Umbraco.Tests.Common
|
||||
{
|
||||
@@ -49,8 +50,9 @@ namespace Umbraco.Tests.Common
|
||||
|
||||
public IRuntimeState GetRuntimeState()
|
||||
{
|
||||
var globalSettings = new GlobalSettingsBuilder().Build();
|
||||
return new RuntimeState(
|
||||
Mock.Of<IGlobalSettings>(),
|
||||
globalSettings,
|
||||
GetUmbracoVersion());
|
||||
}
|
||||
|
||||
@@ -89,7 +91,7 @@ namespace Umbraco.Tests.Common
|
||||
get
|
||||
{
|
||||
if (_ioHelper == null)
|
||||
_ioHelper = new IOHelper(GetHostingEnvironment(), SettingsForTests.GenerateMockGlobalSettings());
|
||||
_ioHelper = new IOHelper(GetHostingEnvironment());
|
||||
return _ioHelper;
|
||||
}
|
||||
}
|
||||
@@ -126,11 +128,11 @@ namespace Umbraco.Tests.Common
|
||||
return relativePath.Replace("~/", bin + "/");
|
||||
}
|
||||
|
||||
public IUmbracoVersion GetUmbracoVersion() => new UmbracoVersion(GetConfigs().Global());
|
||||
public IUmbracoVersion GetUmbracoVersion() => new UmbracoVersion(new GlobalSettingsBuilder().Build());
|
||||
|
||||
public IRegister GetRegister()
|
||||
{
|
||||
return RegisterFactory.Create(GetConfigs().Global());
|
||||
return RegisterFactory.Create(new GlobalSettingsBuilder().Build());
|
||||
}
|
||||
|
||||
public abstract IHostingEnvironment GetHostingEnvironment();
|
||||
|
||||
Reference in New Issue
Block a user