Creates new Umbraco.Tests.Common netstandard project to host the common testing functionality between netframework and netcore, this will be ongoing work (doesn't need to be done all at once)
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Runtime.InteropServices;
|
||||
|
||||
// Umbraco Cms
|
||||
[assembly: InternalsVisibleTo("Umbraco.Tests")]
|
||||
[assembly: InternalsVisibleTo("Umbraco.Tests.Common")]
|
||||
[assembly: InternalsVisibleTo("Umbraco.Tests.Benchmarks")]
|
||||
|
||||
// Allow this to be mocked in our unit tests
|
||||
|
||||
182
src/Umbraco.Tests.Common/SettingsForTests.cs
Normal file
182
src/Umbraco.Tests.Common/SettingsForTests.cs
Normal file
@@ -0,0 +1,182 @@
|
||||
using Moq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Tests.Common
|
||||
{
|
||||
public class SettingsForTests
|
||||
{
|
||||
public SettingsForTests(IUmbracoVersion umbVersion, IIOHelper ioHelper)
|
||||
{
|
||||
_umbVersion = umbVersion;
|
||||
_ioHelper = ioHelper;
|
||||
}
|
||||
|
||||
public IGlobalSettings GenerateMockGlobalSettings()
|
||||
{
|
||||
var config = Mock.Of<IGlobalSettings>(
|
||||
settings =>
|
||||
settings.ConfigurationStatus == _umbVersion.SemanticVersion.ToSemanticString() &&
|
||||
settings.UseHttps == false &&
|
||||
settings.HideTopLevelNodeFromPath == false &&
|
||||
settings.Path == _ioHelper.ResolveUrl("~/umbraco") &&
|
||||
settings.TimeOutInMinutes == 20 &&
|
||||
settings.DefaultUILanguage == "en" &&
|
||||
settings.ReservedPaths == (GlobalSettings.StaticReservedPaths + "~/umbraco") &&
|
||||
settings.ReservedUrls == GlobalSettings.StaticReservedUrls &&
|
||||
settings.UmbracoPath == "~/umbraco" &&
|
||||
settings.UmbracoMediaPath == "~/media" &&
|
||||
settings.UmbracoCssPath == "~/css" &&
|
||||
settings.UmbracoScriptsPath == "~/scripts"
|
||||
);
|
||||
|
||||
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns generated settings which can be stubbed to return whatever values necessary
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IContentSettings GenerateMockContentSettings()
|
||||
{
|
||||
|
||||
var content = new Mock<IContentSettings>();
|
||||
|
||||
//Now configure some defaults - the defaults in the config section classes do NOT pertain to the mocked data!!
|
||||
content.Setup(x => x.ImageAutoFillProperties).Returns(ContentImagingElement.GetDefaultImageAutoFillProperties());
|
||||
content.Setup(x => x.ImageFileTypes).Returns(ContentImagingElement.GetDefaultImageFileTypes());
|
||||
return content.Object;
|
||||
}
|
||||
|
||||
//// from appSettings
|
||||
|
||||
//private readonly IDictionary<string, string> SavedAppSettings = new Dictionary<string, string>();
|
||||
|
||||
//static void SaveSetting(string key)
|
||||
//{
|
||||
// SavedAppSettings[key] = ConfigurationManager.AppSettings[key];
|
||||
//}
|
||||
|
||||
//static void SaveSettings()
|
||||
//{
|
||||
// SaveSetting("umbracoHideTopLevelNodeFromPath");
|
||||
// SaveSetting("umbracoUseDirectoryUrls");
|
||||
// SaveSetting("umbracoPath");
|
||||
// SaveSetting("umbracoReservedPaths");
|
||||
// SaveSetting("umbracoReservedUrls");
|
||||
// SaveSetting("umbracoConfigurationStatus");
|
||||
//}
|
||||
|
||||
|
||||
|
||||
// reset & defaults
|
||||
|
||||
//static SettingsForTests()
|
||||
//{
|
||||
// //SaveSettings();
|
||||
//}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
ResetSettings();
|
||||
GlobalSettings.Reset();
|
||||
|
||||
//foreach (var kvp in SavedAppSettings)
|
||||
// ConfigurationManager.AppSettings.Set(kvp.Key, kvp.Value);
|
||||
|
||||
//// set some defaults that are wrong in the config file?!
|
||||
//// this is annoying, really
|
||||
//HideTopLevelNodeFromPath = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This sets all settings back to default settings
|
||||
/// </summary>
|
||||
private void ResetSettings()
|
||||
{
|
||||
_defaultGlobalSettings = null;
|
||||
}
|
||||
|
||||
private IGlobalSettings _defaultGlobalSettings;
|
||||
private IHostingSettings _defaultHostingSettings;
|
||||
private readonly IUmbracoVersion _umbVersion;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
|
||||
public IGlobalSettings GetDefaultGlobalSettings()
|
||||
{
|
||||
if (_defaultGlobalSettings == null)
|
||||
{
|
||||
_defaultGlobalSettings = GenerateMockGlobalSettings();
|
||||
}
|
||||
return _defaultGlobalSettings;
|
||||
}
|
||||
|
||||
public IHostingSettings GetDefaultHostingSettings()
|
||||
{
|
||||
if (_defaultHostingSettings == null)
|
||||
{
|
||||
_defaultHostingSettings = GenerateMockHostingSettings();
|
||||
}
|
||||
return _defaultHostingSettings;
|
||||
}
|
||||
|
||||
private IHostingSettings GenerateMockHostingSettings()
|
||||
{
|
||||
var config = Mock.Of<IHostingSettings>(
|
||||
settings =>
|
||||
settings.LocalTempStorageLocation == LocalTempStorage.EnvironmentTemp &&
|
||||
settings.DebugMode == false
|
||||
);
|
||||
return config;
|
||||
}
|
||||
|
||||
public IWebRoutingSettings GenerateMockWebRoutingSettings()
|
||||
{
|
||||
var mock = new Mock<IWebRoutingSettings>();
|
||||
|
||||
mock.Setup(x => x.DisableRedirectUrlTracking).Returns(false);
|
||||
mock.Setup(x => x.InternalRedirectPreservesTemplate).Returns(false);
|
||||
mock.Setup(x => x.UrlProviderMode).Returns(UrlMode.Auto.ToString());
|
||||
|
||||
return mock.Object;
|
||||
}
|
||||
|
||||
public IRequestHandlerSettings GenerateMockRequestHandlerSettings()
|
||||
{
|
||||
var mock = new Mock<IRequestHandlerSettings>();
|
||||
|
||||
mock.Setup(x => x.AddTrailingSlash).Returns(true);
|
||||
mock.Setup(x => x.ConvertUrlsToAscii).Returns(false);
|
||||
mock.Setup(x => x.TryConvertUrlsToAscii).Returns(false);
|
||||
mock.Setup(x => x.CharCollection).Returns(RequestHandlerElement.GetDefaultCharReplacements);
|
||||
|
||||
return mock.Object;
|
||||
}
|
||||
|
||||
public ISecuritySettings GenerateMockSecuritySettings()
|
||||
{
|
||||
var security = new Mock<ISecuritySettings>();
|
||||
|
||||
return security.Object;
|
||||
}
|
||||
|
||||
public IUserPasswordConfiguration GenerateMockUserPasswordConfiguration()
|
||||
{
|
||||
var mock = new Mock<IUserPasswordConfiguration>();
|
||||
|
||||
return mock.Object;
|
||||
}
|
||||
|
||||
public IMemberPasswordConfiguration GenerateMockMemberPasswordConfiguration()
|
||||
{
|
||||
var mock = new Mock<IMemberPasswordConfiguration>();
|
||||
|
||||
return mock.Object;
|
||||
}
|
||||
}
|
||||
}
|
||||
144
src/Umbraco.Tests.Common/TestHelperBase.cs
Normal file
144
src/Umbraco.Tests.Common/TestHelperBase.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Moq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Diagnostics;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Runtime;
|
||||
using Umbraco.Core.Serialization;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Core.Sync;
|
||||
using Umbraco.Net;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
namespace Umbraco.Tests.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Common helper properties and methods useful to testing
|
||||
/// </summary>
|
||||
public abstract class TestHelperBase
|
||||
{
|
||||
public TestHelperBase()
|
||||
{
|
||||
IOHelper = new IOHelper(GetHostingEnvironment());
|
||||
MainDom = new MainDom(Mock.Of<ILogger>(), GetHostingEnvironment(), new MainDomSemaphoreLock(Mock.Of<ILogger>(), GetHostingEnvironment()));
|
||||
UriUtility = new UriUtility(GetHostingEnvironment());
|
||||
SettingsForTests = new SettingsForTests(GetUmbracoVersion(), IOHelper);
|
||||
}
|
||||
|
||||
public ITypeFinder GetTypeFinder()
|
||||
{
|
||||
|
||||
var typeFinder = new TypeFinder(Mock.Of<ILogger>(),
|
||||
new DefaultUmbracoAssemblyProvider(typeof(TestHelperBase).Assembly));
|
||||
return typeFinder;
|
||||
}
|
||||
|
||||
public TypeLoader GetMockedTypeLoader()
|
||||
{
|
||||
return new TypeLoader(IOHelper, Mock.Of<ITypeFinder>(), Mock.Of<IAppPolicyCache>(), new DirectoryInfo(IOHelper.MapPath("~/App_Data/TEMP")), Mock.Of<IProfilingLogger>());
|
||||
}
|
||||
|
||||
public Configs GetConfigs()
|
||||
{
|
||||
return GetConfigsFactory().Create(IOHelper, Mock.Of<ILogger>());
|
||||
}
|
||||
public IRuntimeState GetRuntimeState()
|
||||
{
|
||||
return new RuntimeState(
|
||||
Mock.Of<ILogger>(),
|
||||
Mock.Of<IGlobalSettings>(),
|
||||
new Lazy<IMainDom>(),
|
||||
new Lazy<IServerRegistrar>(),
|
||||
GetUmbracoVersion(),
|
||||
GetHostingEnvironment(),
|
||||
GetBackOfficeInfo()
|
||||
);
|
||||
}
|
||||
|
||||
public abstract IBackOfficeInfo GetBackOfficeInfo();
|
||||
|
||||
public IConfigsFactory GetConfigsFactory()
|
||||
{
|
||||
return new ConfigsFactory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current assembly directory.
|
||||
/// </summary>
|
||||
/// <value>The assembly directory.</value>
|
||||
public string CurrentAssemblyDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
var codeBase = typeof(TestHelperBase).Assembly.CodeBase;
|
||||
var uri = new Uri(codeBase);
|
||||
var path = uri.LocalPath;
|
||||
return Path.GetDirectoryName(path);
|
||||
}
|
||||
}
|
||||
|
||||
public IShortStringHelper ShortStringHelper { get; } = new DefaultShortStringHelper(new DefaultShortStringHelperConfig());
|
||||
public IJsonSerializer JsonSerializer { get; } = new JsonNetSerializer();
|
||||
public IVariationContextAccessor VariationContextAccessor { get; } = new TestVariationContextAccessor();
|
||||
public abstract IDbProviderFactoryCreator DbProviderFactoryCreator { get; }
|
||||
public abstract IBulkSqlInsertProvider BulkSqlInsertProvider { get; }
|
||||
public abstract IMarchal Marchal { get; }
|
||||
public ICoreDebug CoreDebug { get; } = new CoreDebug();
|
||||
|
||||
|
||||
public IIOHelper IOHelper { get; }
|
||||
public IMainDom MainDom { get; }
|
||||
public UriUtility UriUtility { get; }
|
||||
public SettingsForTests SettingsForTests { get; }
|
||||
public IWebRoutingSettings WebRoutingSettings => SettingsForTests.GenerateMockWebRoutingSettings();
|
||||
|
||||
/// <summary>
|
||||
/// Maps the given <paramref name="relativePath"/> making it rooted on <see cref="CurrentAssemblyDirectory"/>. <paramref name="relativePath"/> must start with <code>~/</code>
|
||||
/// </summary>
|
||||
/// <param name="relativePath">The relative path.</param>
|
||||
/// <returns></returns>
|
||||
public string MapPathForTest(string relativePath)
|
||||
{
|
||||
if (!relativePath.StartsWith("~/"))
|
||||
throw new ArgumentException("relativePath must start with '~/'", "relativePath");
|
||||
|
||||
return relativePath.Replace("~/", CurrentAssemblyDirectory + "/");
|
||||
}
|
||||
|
||||
public IUmbracoVersion GetUmbracoVersion()
|
||||
{
|
||||
return new UmbracoVersion(GetConfigs().Global());
|
||||
}
|
||||
|
||||
public IRegister GetRegister()
|
||||
{
|
||||
return RegisterFactory.Create(GetConfigs().Global());
|
||||
}
|
||||
|
||||
public abstract IHostingEnvironment GetHostingEnvironment();
|
||||
|
||||
public abstract IIpResolver GetIpResolver();
|
||||
|
||||
public IRequestCache GetRequestCache()
|
||||
{
|
||||
return new DictionaryAppCache();
|
||||
}
|
||||
|
||||
public IPublishedUrlProvider GetPublishedUrlProvider()
|
||||
{
|
||||
var mock = new Mock<IPublishedUrlProvider>();
|
||||
|
||||
return mock.Object;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Tests.Testing.Objects.Accessors
|
||||
namespace Umbraco.Tests.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides an implementation of <see cref="IVariationContextAccessor"/> for tests.
|
||||
18
src/Umbraco.Tests.Common/Umbraco.Tests.Common.csproj
Normal file
18
src/Umbraco.Tests.Common/Umbraco.Tests.Common.csproj
Normal file
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Moq" Version="4.13.1" />
|
||||
<PackageReference Include="nunit" Version="3.12.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Umbraco.Configuration\Umbraco.Configuration.csproj" />
|
||||
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj" />
|
||||
<ProjectReference Include="..\Umbraco.Infrastructure\Umbraco.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -10,6 +10,7 @@ using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Serialization;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
|
||||
@@ -7,6 +7,7 @@ using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Tests.LegacyXmlPublishedCache;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
|
||||
@@ -20,6 +20,7 @@ using Umbraco.Core.Scoping;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Changes;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Tests.Strings;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing.Objects;
|
||||
@@ -63,7 +64,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs);
|
||||
var globalSettings = new GlobalSettings(TestHelper.IOHelper);
|
||||
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
||||
configs.Add(SettingsForTests.GenerateMockContentSettings);
|
||||
configs.Add(TestHelpers.SettingsForTests.GenerateMockContentSettings);
|
||||
configs.Add<IGlobalSettings>(() => globalSettings);
|
||||
|
||||
Mock.Get(factory).Setup(x => x.GetInstance(typeof(IPublishedModelFactory))).Returns(PublishedModelFactory);
|
||||
|
||||
@@ -18,6 +18,7 @@ using Umbraco.Core.Scoping;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Changes;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Tests.Strings;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing.Objects;
|
||||
@@ -55,7 +56,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
var configs = TestHelper.GetConfigs();
|
||||
Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs);
|
||||
var globalSettings = new GlobalSettings(TestHelper.IOHelper);
|
||||
configs.Add(SettingsForTests.GenerateMockContentSettings);
|
||||
configs.Add(TestHelpers.SettingsForTests.GenerateMockContentSettings);
|
||||
configs.Add<IGlobalSettings>(() => globalSettings);
|
||||
|
||||
var publishedModelFactory = new NoopPublishedModelFactory();
|
||||
|
||||
@@ -21,6 +21,7 @@ using Umbraco.Core.Strings;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
using Current = Umbraco.Web.Composing.Current;
|
||||
using Umbraco.Tests.Common;
|
||||
|
||||
namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@ using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.Runtime;
|
||||
using File = System.IO.File;
|
||||
using Current = Umbraco.Web.Composing.Current;
|
||||
using Umbraco.Tests.Common;
|
||||
|
||||
namespace Umbraco.Tests.Runtimes
|
||||
{
|
||||
@@ -120,8 +121,8 @@ namespace Umbraco.Tests.Runtimes
|
||||
.Append<DistributedCacheBinderComponent>();
|
||||
|
||||
// configure
|
||||
composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
|
||||
composition.Configs.Add(SettingsForTests.GenerateMockContentSettings);
|
||||
composition.Configs.Add(TestHelpers.SettingsForTests.GetDefaultGlobalSettings);
|
||||
composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockContentSettings);
|
||||
|
||||
// create and register the factory
|
||||
Current.Factory = factory = composition.CreateFactory();
|
||||
@@ -159,7 +160,7 @@ namespace Umbraco.Tests.Runtimes
|
||||
var scopeProvider = factory.GetInstance<IScopeProvider>();
|
||||
using (var scope = scopeProvider.CreateScope())
|
||||
{
|
||||
var creator = new DatabaseSchemaCreator(scope.Database, logger, umbracoVersion, SettingsForTests.GetDefaultGlobalSettings());
|
||||
var creator = new DatabaseSchemaCreator(scope.Database, logger, umbracoVersion, TestHelpers.SettingsForTests.GetDefaultGlobalSettings());
|
||||
creator.InitializeDatabaseSchema();
|
||||
scope.Complete();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Core.Sync;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Tests.Strings;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
|
||||
@@ -15,7 +15,7 @@ using Umbraco.Web;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.Security;
|
||||
|
||||
using Umbraco.Tests.Common;
|
||||
|
||||
namespace Umbraco.Tests.Security
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.PublishedCache.NuCache;
|
||||
using Umbraco.Web.Security.Providers;
|
||||
using Umbraco.Tests.Common;
|
||||
|
||||
namespace Umbraco.Tests.Services
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ using Umbraco.Core.Request;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Tests.PublishedContent;
|
||||
using Umbraco.Tests.TestHelpers.Stubs;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
|
||||
@@ -25,6 +25,7 @@ using Umbraco.Core.Logging;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
using Umbraco.Web.Security.Providers;
|
||||
using Umbraco.Tests.Strings;
|
||||
using Umbraco.Tests.Common;
|
||||
|
||||
namespace Umbraco.Tests.TestHelpers.ControllerTesting
|
||||
{
|
||||
|
||||
@@ -1,55 +1,19 @@
|
||||
using System.IO;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Tests.TestHelpers
|
||||
{
|
||||
public class SettingsForTests
|
||||
{
|
||||
public static IGlobalSettings GenerateMockGlobalSettings()
|
||||
{
|
||||
var config = Mock.Of<IGlobalSettings>(
|
||||
settings =>
|
||||
settings.ConfigurationStatus == TestHelper.GetUmbracoVersion().SemanticVersion.ToSemanticString() &&
|
||||
settings.UseHttps == false &&
|
||||
settings.HideTopLevelNodeFromPath == false &&
|
||||
settings.Path == TestHelper.IOHelper.ResolveUrl("~/umbraco") &&
|
||||
settings.TimeOutInMinutes == 20 &&
|
||||
settings.DefaultUILanguage == "en" &&
|
||||
settings.ReservedPaths == (GlobalSettings.StaticReservedPaths + "~/umbraco") &&
|
||||
settings.ReservedUrls == GlobalSettings.StaticReservedUrls &&
|
||||
settings.UmbracoPath == "~/umbraco" &&
|
||||
settings.UmbracoMediaPath == "~/media" &&
|
||||
settings.UmbracoCssPath == "~/css" &&
|
||||
settings.UmbracoScriptsPath == "~/scripts"
|
||||
);
|
||||
private static Common.SettingsForTests _settingsForTests = new Common.SettingsForTests(TestHelper.GetUmbracoVersion(), TestHelper.IOHelper);
|
||||
|
||||
|
||||
|
||||
return config;
|
||||
}
|
||||
public static IGlobalSettings GenerateMockGlobalSettings() => _settingsForTests.GenerateMockGlobalSettings();
|
||||
|
||||
/// <summary>
|
||||
/// Returns generated settings which can be stubbed to return whatever values necessary
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IContentSettings GenerateMockContentSettings()
|
||||
{
|
||||
|
||||
var content = new Mock<IContentSettings>();
|
||||
|
||||
//Now configure some defaults - the defaults in the config section classes do NOT pertain to the mocked data!!
|
||||
content.Setup(x => x.ImageAutoFillProperties).Returns(ContentImagingElement.GetDefaultImageAutoFillProperties());
|
||||
content.Setup(x => x.ImageFileTypes).Returns(ContentImagingElement.GetDefaultImageFileTypes());
|
||||
return content.Object;
|
||||
}
|
||||
public static IContentSettings GenerateMockContentSettings() => _settingsForTests.GenerateMockContentSettings();
|
||||
|
||||
//// from appSettings
|
||||
|
||||
@@ -79,100 +43,20 @@ namespace Umbraco.Tests.TestHelpers
|
||||
// //SaveSettings();
|
||||
//}
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
ResetSettings();
|
||||
GlobalSettings.Reset();
|
||||
public static void Reset() => _settingsForTests.Reset();
|
||||
|
||||
//foreach (var kvp in SavedAppSettings)
|
||||
// ConfigurationManager.AppSettings.Set(kvp.Key, kvp.Value);
|
||||
internal static IGlobalSettings GetDefaultGlobalSettings() => _settingsForTests.GetDefaultGlobalSettings();
|
||||
|
||||
//// set some defaults that are wrong in the config file?!
|
||||
//// this is annoying, really
|
||||
//HideTopLevelNodeFromPath = false;
|
||||
}
|
||||
internal static IHostingSettings GetDefaultHostingSettings() => _settingsForTests.GetDefaultHostingSettings();
|
||||
|
||||
/// <summary>
|
||||
/// This sets all settings back to default settings
|
||||
/// </summary>
|
||||
private static void ResetSettings()
|
||||
{
|
||||
_defaultGlobalSettings = null;
|
||||
}
|
||||
public static IWebRoutingSettings GenerateMockWebRoutingSettings() => _settingsForTests.GenerateMockWebRoutingSettings();
|
||||
|
||||
private static IGlobalSettings _defaultGlobalSettings;
|
||||
private static IHostingSettings _defaultHostingSettings;
|
||||
public static IRequestHandlerSettings GenerateMockRequestHandlerSettings() => _settingsForTests.GenerateMockRequestHandlerSettings();
|
||||
|
||||
internal static IGlobalSettings GetDefaultGlobalSettings()
|
||||
{
|
||||
if (_defaultGlobalSettings == null)
|
||||
{
|
||||
_defaultGlobalSettings = GenerateMockGlobalSettings();
|
||||
}
|
||||
return _defaultGlobalSettings;
|
||||
}
|
||||
public static ISecuritySettings GenerateMockSecuritySettings() => _settingsForTests.GenerateMockSecuritySettings();
|
||||
|
||||
internal static IHostingSettings GetDefaultHostingSettings()
|
||||
{
|
||||
if (_defaultHostingSettings == null)
|
||||
{
|
||||
_defaultHostingSettings = GenerateMockHostingSettings();
|
||||
}
|
||||
return _defaultHostingSettings;
|
||||
}
|
||||
public static IUserPasswordConfiguration GenerateMockUserPasswordConfiguration() => _settingsForTests.GenerateMockUserPasswordConfiguration();
|
||||
|
||||
private static IHostingSettings GenerateMockHostingSettings()
|
||||
{
|
||||
var config = Mock.Of<IHostingSettings>(
|
||||
settings =>
|
||||
settings.LocalTempStorageLocation == LocalTempStorage.EnvironmentTemp &&
|
||||
settings.DebugMode == false
|
||||
);
|
||||
return config;
|
||||
}
|
||||
|
||||
public static IWebRoutingSettings GenerateMockWebRoutingSettings()
|
||||
{
|
||||
var mock = new Mock<IWebRoutingSettings>();
|
||||
|
||||
mock.Setup(x => x.DisableRedirectUrlTracking).Returns(false);
|
||||
mock.Setup(x => x.InternalRedirectPreservesTemplate).Returns(false);
|
||||
mock.Setup(x => x.UrlProviderMode).Returns(UrlMode.Auto.ToString());
|
||||
|
||||
return mock.Object;
|
||||
}
|
||||
|
||||
public static IRequestHandlerSettings GenerateMockRequestHandlerSettings()
|
||||
{
|
||||
var mock = new Mock<IRequestHandlerSettings>();
|
||||
|
||||
mock.Setup(x => x.AddTrailingSlash).Returns(true);
|
||||
mock.Setup(x => x.ConvertUrlsToAscii).Returns(false);
|
||||
mock.Setup(x => x.TryConvertUrlsToAscii).Returns(false);
|
||||
mock.Setup(x => x.CharCollection).Returns(RequestHandlerElement.GetDefaultCharReplacements);
|
||||
|
||||
return mock.Object;
|
||||
}
|
||||
|
||||
public static ISecuritySettings GenerateMockSecuritySettings()
|
||||
{
|
||||
var security = new Mock<ISecuritySettings>();
|
||||
|
||||
return security.Object;
|
||||
}
|
||||
|
||||
public static IUserPasswordConfiguration GenerateMockUserPasswordConfiguration()
|
||||
{
|
||||
var mock = new Mock<IUserPasswordConfiguration>();
|
||||
|
||||
return mock.Object;
|
||||
}
|
||||
|
||||
public static IMemberPasswordConfiguration GenerateMockMemberPasswordConfiguration()
|
||||
{
|
||||
var mock = new Mock<IMemberPasswordConfiguration>();
|
||||
|
||||
return mock.Object;
|
||||
}
|
||||
public static IMemberPasswordConfiguration GenerateMockMemberPasswordConfiguration() => _settingsForTests.GenerateMockMemberPasswordConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,11 @@ using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Runtime;
|
||||
using Umbraco.Core.Serialization;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Core.Sync;
|
||||
using Umbraco.Net;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Hosting;
|
||||
using Umbraco.Web.Routing;
|
||||
@@ -42,89 +40,64 @@ namespace Umbraco.Tests.TestHelpers
|
||||
/// </summary>
|
||||
public static class TestHelper
|
||||
{
|
||||
|
||||
public static ITypeFinder GetTypeFinder()
|
||||
private static TestHelperInternal _testHelperInternal = new TestHelperInternal();
|
||||
private class TestHelperInternal : TestHelperBase
|
||||
{
|
||||
public override IDbProviderFactoryCreator DbProviderFactoryCreator { get; } = new UmbracoDbProviderFactoryCreator(Constants.DbProviderNames.SqlCe);
|
||||
|
||||
var typeFinder = new TypeFinder(Mock.Of<ILogger>(),
|
||||
new DefaultUmbracoAssemblyProvider(typeof(TestHelper).Assembly));
|
||||
return typeFinder;
|
||||
public override IBulkSqlInsertProvider BulkSqlInsertProvider { get; } = new SqlCeBulkSqlInsertProvider();
|
||||
|
||||
public override IMarchal Marchal { get; } = new FrameworkMarchal();
|
||||
|
||||
public override IBackOfficeInfo GetBackOfficeInfo()
|
||||
=> new AspNetBackOfficeInfo(SettingsForTests.GenerateMockGlobalSettings(), TestHelper.IOHelper, Mock.Of<ILogger>(), SettingsForTests.GenerateMockWebRoutingSettings());
|
||||
|
||||
public override IHostingEnvironment GetHostingEnvironment()
|
||||
=> new AspNetHostingEnvironment(SettingsForTests.GetDefaultHostingSettings());
|
||||
|
||||
public override IIpResolver GetIpResolver()
|
||||
=> new AspNetIpResolver();
|
||||
}
|
||||
|
||||
public static TypeLoader GetMockedTypeLoader()
|
||||
{
|
||||
return new TypeLoader(IOHelper, Mock.Of<ITypeFinder>(), Mock.Of<IAppPolicyCache>(), new DirectoryInfo(IOHelper.MapPath("~/App_Data/TEMP")), Mock.Of<IProfilingLogger>());
|
||||
}
|
||||
public static ITypeFinder GetTypeFinder() => _testHelperInternal.GetTypeFinder();
|
||||
|
||||
public static Configs GetConfigs()
|
||||
{
|
||||
return GetConfigsFactory().Create(IOHelper, Mock.Of<ILogger>());
|
||||
}
|
||||
public static IRuntimeState GetRuntimeState()
|
||||
{
|
||||
return new RuntimeState(
|
||||
Mock.Of<ILogger>(),
|
||||
Mock.Of<IGlobalSettings>(),
|
||||
new Lazy<IMainDom>(),
|
||||
new Lazy<IServerRegistrar>(),
|
||||
TestHelper.GetUmbracoVersion(),
|
||||
TestHelper.GetHostingEnvironment(),
|
||||
TestHelper.GetBackOfficeInfo()
|
||||
);
|
||||
}
|
||||
public static TypeLoader GetMockedTypeLoader() => _testHelperInternal.GetMockedTypeLoader();
|
||||
|
||||
public static IBackOfficeInfo GetBackOfficeInfo()
|
||||
{
|
||||
return new AspNetBackOfficeInfo(SettingsForTests.GenerateMockGlobalSettings(), TestHelper.IOHelper, Mock.Of<ILogger>(), SettingsForTests.GenerateMockWebRoutingSettings());
|
||||
}
|
||||
public static Configs GetConfigs() => _testHelperInternal.GetConfigs();
|
||||
|
||||
public static IConfigsFactory GetConfigsFactory()
|
||||
{
|
||||
return new ConfigsFactory();
|
||||
}
|
||||
public static IRuntimeState GetRuntimeState() => _testHelperInternal.GetRuntimeState();
|
||||
|
||||
public static IBackOfficeInfo GetBackOfficeInfo() => _testHelperInternal.GetBackOfficeInfo();
|
||||
|
||||
public static IConfigsFactory GetConfigsFactory() => _testHelperInternal.GetConfigsFactory();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current assembly directory.
|
||||
/// </summary>
|
||||
/// <value>The assembly directory.</value>
|
||||
public static string CurrentAssemblyDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
var codeBase = typeof(TestHelper).Assembly.CodeBase;
|
||||
var uri = new Uri(codeBase);
|
||||
var path = uri.LocalPath;
|
||||
return Path.GetDirectoryName(path);
|
||||
}
|
||||
}
|
||||
public static string CurrentAssemblyDirectory => _testHelperInternal.CurrentAssemblyDirectory;
|
||||
|
||||
public static IShortStringHelper ShortStringHelper { get; } = new DefaultShortStringHelper(new DefaultShortStringHelperConfig());
|
||||
public static IJsonSerializer JsonSerializer { get; } = new JsonNetSerializer();
|
||||
public static IVariationContextAccessor VariationContextAccessor { get; } = new TestVariationContextAccessor();
|
||||
public static IDbProviderFactoryCreator DbProviderFactoryCreator { get; } = new UmbracoDbProviderFactoryCreator(Constants.DbProviderNames.SqlCe);
|
||||
public static IBulkSqlInsertProvider BulkSqlInsertProvider { get; } = new SqlCeBulkSqlInsertProvider();
|
||||
public static IMarchal Marchal { get; } = new FrameworkMarchal();
|
||||
public static ICoreDebug CoreDebug { get; } = new CoreDebug();
|
||||
public static IShortStringHelper ShortStringHelper => _testHelperInternal.ShortStringHelper;
|
||||
public static IJsonSerializer JsonSerializer => _testHelperInternal.JsonSerializer;
|
||||
public static IVariationContextAccessor VariationContextAccessor => _testHelperInternal.VariationContextAccessor;
|
||||
public static IDbProviderFactoryCreator DbProviderFactoryCreator => _testHelperInternal.DbProviderFactoryCreator;
|
||||
public static IBulkSqlInsertProvider BulkSqlInsertProvider => _testHelperInternal.BulkSqlInsertProvider;
|
||||
public static IMarchal Marchal => _testHelperInternal.Marchal;
|
||||
public static ICoreDebug CoreDebug => _testHelperInternal.CoreDebug;
|
||||
|
||||
|
||||
public static IIOHelper IOHelper { get; } = new IOHelper(GetHostingEnvironment());
|
||||
public static IMainDom MainDom { get; } = new MainDom(Mock.Of<ILogger>(), GetHostingEnvironment(), new MainDomSemaphoreLock(Mock.Of<ILogger>(), GetHostingEnvironment()));
|
||||
public static UriUtility UriUtility { get; } = new UriUtility(GetHostingEnvironment());
|
||||
public static IIOHelper IOHelper => _testHelperInternal.IOHelper;
|
||||
public static IMainDom MainDom => _testHelperInternal.MainDom;
|
||||
public static UriUtility UriUtility => _testHelperInternal.UriUtility;
|
||||
|
||||
public static IWebRoutingSettings WebRoutingSettings => SettingsForTests.GenerateMockWebRoutingSettings();
|
||||
public static IWebRoutingSettings WebRoutingSettings => _testHelperInternal.WebRoutingSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Maps the given <paramref name="relativePath"/> making it rooted on <see cref="CurrentAssemblyDirectory"/>. <paramref name="relativePath"/> must start with <code>~/</code>
|
||||
/// </summary>
|
||||
/// <param name="relativePath">The relative path.</param>
|
||||
/// <returns></returns>
|
||||
public static string MapPathForTest(string relativePath)
|
||||
{
|
||||
if (!relativePath.StartsWith("~/"))
|
||||
throw new ArgumentException("relativePath must start with '~/'", "relativePath");
|
||||
|
||||
return relativePath.Replace("~/", CurrentAssemblyDirectory + "/");
|
||||
}
|
||||
public static string MapPathForTest(string relativePath) => _testHelperInternal.MapPathForTest(relativePath);
|
||||
|
||||
public static void InitializeContentDirectories()
|
||||
{
|
||||
@@ -171,6 +144,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
File.Delete(umbracoSettingsFile);
|
||||
}
|
||||
|
||||
// TODO: Move to Assertions or AssertHelper
|
||||
// FIXME: obsolete the dateTimeFormat thing and replace with dateDelta
|
||||
public static void AssertPropertyValuesAreEqual(object actual, object expected, string dateTimeFormat = null, Func<IEnumerable, IEnumerable> sorter = null, string[] ignoreProperties = null)
|
||||
{
|
||||
@@ -314,6 +288,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Move to MockedValueEditors.cs
|
||||
public static DataValueEditor CreateDataValueEditor(string name)
|
||||
{
|
||||
var valueType = (ValueTypes.IsValue(name)) ? name : ValueTypes.String;
|
||||
@@ -332,30 +307,15 @@ namespace Umbraco.Tests.TestHelpers
|
||||
}
|
||||
|
||||
|
||||
public static IUmbracoVersion GetUmbracoVersion()
|
||||
{
|
||||
return new UmbracoVersion(GetConfigs().Global());
|
||||
}
|
||||
public static IUmbracoVersion GetUmbracoVersion() => _testHelperInternal.GetUmbracoVersion();
|
||||
|
||||
public static IRegister GetRegister()
|
||||
{
|
||||
return RegisterFactory.Create(GetConfigs().Global());
|
||||
}
|
||||
public static IRegister GetRegister() => _testHelperInternal.GetRegister();
|
||||
|
||||
public static IHostingEnvironment GetHostingEnvironment()
|
||||
{
|
||||
return new AspNetHostingEnvironment(SettingsForTests.GetDefaultHostingSettings());
|
||||
}
|
||||
public static IHostingEnvironment GetHostingEnvironment() => _testHelperInternal.GetHostingEnvironment();
|
||||
|
||||
public static IIpResolver GetIpResolver()
|
||||
{
|
||||
return new AspNetIpResolver();
|
||||
}
|
||||
public static IIpResolver GetIpResolver() => _testHelperInternal.GetIpResolver();
|
||||
|
||||
public static IRequestCache GetRequestCache()
|
||||
{
|
||||
return new DictionaryAppCache();
|
||||
}
|
||||
public static IRequestCache GetRequestCache() => _testHelperInternal.GetRequestCache();
|
||||
|
||||
public static IHttpContextAccessor GetHttpContextAccessor(HttpContextBase httpContextBase = null)
|
||||
{
|
||||
@@ -376,11 +336,6 @@ namespace Umbraco.Tests.TestHelpers
|
||||
return mock.Object;
|
||||
}
|
||||
|
||||
public static IPublishedUrlProvider GetPublishedUrlProvider()
|
||||
{
|
||||
var mock = new Mock<IPublishedUrlProvider>();
|
||||
|
||||
return mock.Object;
|
||||
}
|
||||
public static IPublishedUrlProvider GetPublishedUrlProvider() => _testHelperInternal.GetPublishedUrlProvider();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
|
||||
@@ -32,6 +32,7 @@ using Umbraco.Core.Persistence.Repositories;
|
||||
using Umbraco.Tests.LegacyXmlPublishedCache;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
using Umbraco.Web.WebApi;
|
||||
using Umbraco.Tests.Common;
|
||||
|
||||
namespace Umbraco.Tests.TestHelpers
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using NUnit.Framework.Internal;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
using Umbraco.Web;
|
||||
@@ -21,7 +22,7 @@ namespace Umbraco.Tests.Testing.Objects
|
||||
IHttpContextAccessor httpContextAccessor = null,
|
||||
IPublishedUrlProvider publishedUrlProvider = null)
|
||||
{
|
||||
if (globalSettings == null) globalSettings = SettingsForTests.GenerateMockGlobalSettings();
|
||||
if (globalSettings == null) globalSettings = TestHelpers.SettingsForTests.GenerateMockGlobalSettings();
|
||||
if (umbracoContextAccessor == null) umbracoContextAccessor = new TestUmbracoContextAccessor();
|
||||
if (httpContextAccessor == null) httpContextAccessor = TestHelper.GetHttpContextAccessor();
|
||||
if (publishedUrlProvider == null) publishedUrlProvider = TestHelper.GetPublishedUrlProvider();
|
||||
|
||||
@@ -63,6 +63,8 @@ using Umbraco.Web.Security;
|
||||
using Umbraco.Web.Security.Providers;
|
||||
using Umbraco.Web.Trees;
|
||||
using Current = Umbraco.Web.Composing.Current;
|
||||
using Umbraco.Tests.Common;
|
||||
|
||||
namespace Umbraco.Tests.Testing
|
||||
{
|
||||
/// <summary>
|
||||
@@ -138,7 +140,7 @@ namespace Umbraco.Tests.Testing
|
||||
|
||||
protected virtual IProfilingLogger ProfilingLogger => Factory.GetInstance<IProfilingLogger>();
|
||||
|
||||
protected IHostingEnvironment HostingEnvironment { get; } = new AspNetHostingEnvironment(SettingsForTests.GetDefaultHostingSettings());
|
||||
protected IHostingEnvironment HostingEnvironment { get; } = new AspNetHostingEnvironment(TestHelpers.SettingsForTests.GetDefaultHostingSettings());
|
||||
protected IIpResolver IpResolver => Factory.GetInstance<IIpResolver>();
|
||||
protected IBackOfficeInfo BackOfficeInfo => Factory.GetInstance<IBackOfficeInfo>();
|
||||
protected AppCaches AppCaches => Factory.GetInstance<AppCaches>();
|
||||
@@ -173,8 +175,8 @@ namespace Umbraco.Tests.Testing
|
||||
|
||||
TypeFinder = new TypeFinder(logger, new DefaultUmbracoAssemblyProvider(GetType().Assembly));
|
||||
var appCaches = GetAppCaches();
|
||||
var globalSettings = SettingsForTests.GetDefaultGlobalSettings();
|
||||
var settings = SettingsForTests.GenerateMockWebRoutingSettings();
|
||||
var globalSettings = TestHelpers.SettingsForTests.GetDefaultGlobalSettings();
|
||||
var settings = TestHelpers.SettingsForTests.GenerateMockWebRoutingSettings();
|
||||
|
||||
IBackOfficeInfo backOfficeInfo = new AspNetBackOfficeInfo(globalSettings, IOHelper, logger, settings);
|
||||
IIpResolver ipResolver = new AspNetIpResolver();
|
||||
@@ -321,7 +323,7 @@ namespace Umbraco.Tests.Testing
|
||||
Composition.RegisterUnique<IPublishedUrlProvider>(factory =>
|
||||
new UrlProvider(
|
||||
factory.GetInstance<IUmbracoContextAccessor>(),
|
||||
SettingsForTests.GenerateMockWebRoutingSettings(),
|
||||
TestHelpers.SettingsForTests.GenerateMockWebRoutingSettings(),
|
||||
new UrlProviderCollection(Enumerable.Empty<IUrlProvider>()),
|
||||
new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()),
|
||||
factory.GetInstance<IVariationContextAccessor>()
|
||||
@@ -411,14 +413,14 @@ namespace Umbraco.Tests.Testing
|
||||
|
||||
protected virtual void ComposeSettings()
|
||||
{
|
||||
Composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
|
||||
Composition.Configs.Add(SettingsForTests.GetDefaultHostingSettings);
|
||||
Composition.Configs.Add(SettingsForTests.GenerateMockRequestHandlerSettings);
|
||||
Composition.Configs.Add(SettingsForTests.GenerateMockWebRoutingSettings);
|
||||
Composition.Configs.Add(SettingsForTests.GenerateMockSecuritySettings);
|
||||
Composition.Configs.Add(SettingsForTests.GenerateMockUserPasswordConfiguration);
|
||||
Composition.Configs.Add(SettingsForTests.GenerateMockMemberPasswordConfiguration);
|
||||
Composition.Configs.Add(SettingsForTests.GenerateMockContentSettings);
|
||||
Composition.Configs.Add(TestHelpers.SettingsForTests.GetDefaultGlobalSettings);
|
||||
Composition.Configs.Add(TestHelpers.SettingsForTests.GetDefaultHostingSettings);
|
||||
Composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockRequestHandlerSettings);
|
||||
Composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockWebRoutingSettings);
|
||||
Composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockSecuritySettings);
|
||||
Composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockUserPasswordConfiguration);
|
||||
Composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockMemberPasswordConfiguration);
|
||||
Composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockContentSettings);
|
||||
|
||||
//Composition.Configs.Add<IUserPasswordConfiguration>(() => new DefaultUserPasswordConfig());
|
||||
}
|
||||
@@ -548,7 +550,7 @@ namespace Umbraco.Tests.Testing
|
||||
|
||||
// reset all other static things that should not be static ;(
|
||||
UriUtility.ResetAppDomainAppVirtualPath(HostingEnvironment);
|
||||
SettingsForTests.Reset(); // FIXME: should it be optional?
|
||||
TestHelpers.SettingsForTests.Reset(); // FIXME: should it be optional?
|
||||
|
||||
// clear static events
|
||||
DocumentRepository.ClearScopeEvents();
|
||||
|
||||
@@ -222,7 +222,6 @@
|
||||
<Compile Include="TestHelpers\Entities\MockedUserGroup.cs" />
|
||||
<Compile Include="Testing\Objects\Accessors\NoHttpContextAccessor.cs" />
|
||||
<Compile Include="TestHelpers\Stubs\TestExamineManager.cs" />
|
||||
<Compile Include="Testing\Objects\Accessors\TestVariationContextAccessor.cs" />
|
||||
<Compile Include="Testing\ContentBaseExtensions.cs" />
|
||||
<Compile Include="Testing\Objects\Accessors\TestDefaultCultureAccessor.cs" />
|
||||
<Compile Include="Testing\Objects\TestUmbracoContextFactory.cs" />
|
||||
@@ -586,6 +585,10 @@
|
||||
<Project>{f6de8da0-07cc-4ef2-8a59-2bc81dbb3830}</Project>
|
||||
<Name>Umbraco.PublishedCache.NuCache</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Umbraco.Tests.Common\Umbraco.Tests.Common.csproj">
|
||||
<Project>{a499779c-1b3b-48a8-b551-458e582e6e96}</Project>
|
||||
<Name>Umbraco.Tests.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Umbraco.Web\Umbraco.Web.csproj">
|
||||
<Project>{651E1350-91B6-44B7-BD60-7207006D7003}</Project>
|
||||
<Name>Umbraco.Web</Name>
|
||||
|
||||
@@ -13,6 +13,7 @@ using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Stubs;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
|
||||
@@ -11,6 +11,7 @@ using Umbraco.Core.Dictionary;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
@@ -156,7 +157,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
var content = Mock.Of<IPublishedContent>(publishedContent => publishedContent.Id == 12345);
|
||||
|
||||
|
||||
var publishedRouter = BaseWebTest.CreatePublishedRouter(SettingsForTests.GenerateMockWebRoutingSettings());
|
||||
var publishedRouter = BaseWebTest.CreatePublishedRouter(TestHelpers.SettingsForTests.GenerateMockWebRoutingSettings());
|
||||
var frequest = publishedRouter.CreateRequest(umbracoContext, new Uri("http://localhost/test"));
|
||||
frequest.PublishedContent = content;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ using Umbraco.Tests.LegacyXmlPublishedCache;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Mvc;
|
||||
@@ -387,7 +388,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
{
|
||||
var umbracoContext = GetUmbracoContext("/dang", 0);
|
||||
|
||||
var publishedRouter = BaseWebTest.CreatePublishedRouter(SettingsForTests.GenerateMockWebRoutingSettings());
|
||||
var publishedRouter = BaseWebTest.CreatePublishedRouter(TestHelpers.SettingsForTests.GenerateMockWebRoutingSettings());
|
||||
var frequest = publishedRouter.CreateRequest(umbracoContext, new Uri("http://localhost/dang"));
|
||||
|
||||
frequest.Culture = CultureInfo.InvariantCulture;
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Web.Routing;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Stubs;
|
||||
using Umbraco.Tests.Testing;
|
||||
|
||||
@@ -117,9 +117,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Examine.Lucene", "U
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Web.BackOffice", "Umbraco.Web.BackOffice\Umbraco.Web.BackOffice.csproj", "{9B95EEF7-63FE-4432-8C63-166BE9C1A929}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Web.UI.NetCore", "Umbraco.Web.UI.NetCore\Umbraco.Web.UI.NetCore.csproj", "{DCDFE97C-5630-4F6F-855D-8AEEB96556A5}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Web.UI.NetCore", "Umbraco.Web.UI.NetCore\Umbraco.Web.UI.NetCore.csproj", "{DCDFE97C-5630-4F6F-855D-8AEEB96556A5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Web.Website", "Umbraco.Web.Website\Umbraco.Web.Website.csproj", "{5A246D54-3109-4D2B-BE7D-FC0787D126AE}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Web.Website", "Umbraco.Web.Website\Umbraco.Web.Website.csproj", "{5A246D54-3109-4D2B-BE7D-FC0787D126AE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Tests.Common", "Umbraco.Tests.Common\Umbraco.Tests.Common.csproj", "{A499779C-1B3B-48A8-B551-458E582E6E96}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -189,6 +191,10 @@ Global
|
||||
{5A246D54-3109-4D2B-BE7D-FC0787D126AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5A246D54-3109-4D2B-BE7D-FC0787D126AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5A246D54-3109-4D2B-BE7D-FC0787D126AE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A499779C-1B3B-48A8-B551-458E582E6E96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A499779C-1B3B-48A8-B551-458E582E6E96}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A499779C-1B3B-48A8-B551-458E582E6E96}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A499779C-1B3B-48A8-B551-458E582E6E96}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -202,6 +208,7 @@ Global
|
||||
{3A33ADC9-C6C0-4DB1-A613-A9AF0210DF3D} = {B5BD12C1-A454-435E-8A46-FF4A364C0382}
|
||||
{C7311C00-2184-409B-B506-52A5FAEA8736} = {FD962632-184C-4005-A5F3-E705D92FC645}
|
||||
{FB5676ED-7A69-492C-B802-E7B24144C0FC} = {B5BD12C1-A454-435E-8A46-FF4A364C0382}
|
||||
{A499779C-1B3B-48A8-B551-458E582E6E96} = {B5BD12C1-A454-435E-8A46-FF4A364C0382}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7A0F2E34-D2AF-4DAB-86A0-7D7764B3D0EC}
|
||||
|
||||
Reference in New Issue
Block a user