Updates DefaultShortStringHelperTests to ensure that umb config is mocked.

This commit is contained in:
Shannon
2013-11-13 12:41:02 +11:00
parent 8dbdd67c98
commit fd91340e75
4 changed files with 50 additions and 16 deletions

View File

@@ -6,17 +6,20 @@ using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Strings;
using Umbraco.Core.ObjectResolution;
using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.CoreStrings
{
[TestFixture]
public class DefaultShortStringHelperTests
public class DefaultShortStringHelperTests : BaseUmbracoConfigurationTest
{
private DefaultShortStringHelper _helper;
[SetUp]
public void Setup()
public override void Initialize()
{
base.Initialize();
// NOTE: it is not possible to configure the helper once it has been assigned
// to the resolver and resolution has frozen. but, obviously, it is possible
// to configure filters and then to alter these filters after resolution has
@@ -37,8 +40,9 @@ namespace Umbraco.Tests.CoreStrings
}
[TearDown]
public void TearDown()
public override void TearDown()
{
base.TearDown();
ShortStringHelperResolver.Reset();
}

View File

@@ -1,7 +1,6 @@
using AutoMapper;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Models.Mapping;
using Umbraco.Core.ObjectResolution;
using Umbraco.Core.Persistence;
@@ -19,22 +18,16 @@ namespace Umbraco.Tests.TestHelpers
/// ensures everything is torn down properly.
/// </summary>
[TestFixture]
public abstract class BaseUmbracoApplicationTest
public abstract class BaseUmbracoApplicationTest : BaseUmbracoConfigurationTest
{
[SetUp]
public virtual void Initialize()
public override void Initialize()
{
TestHelper.SetupLog4NetForTests();
base.Initialize();
TestHelper.InitializeContentDirectories();
TestHelper.EnsureUmbracoSettingsConfig();
//mock the Umbraco settings that we need
var settings = SettingsForTests.GetMockSettings();
//sets the global singleton to use the mocked format
SettingsForTests.ConfigureSettings(settings);
//set our local variable for tests to use (preferably)
UmbracoSettings = settings;
//Create the legacy prop-eds mapping
LegacyPropertyEditorIdToAliasConverter.CreateMappingsForCoreEditors();
@@ -46,8 +39,10 @@ namespace Umbraco.Tests.TestHelpers
}
[TearDown]
public virtual void TearDown()
public override void TearDown()
{
base.TearDown();
//reset settings
SettingsForTests.Reset();
UmbracoContext.Current = null;
@@ -72,7 +67,7 @@ namespace Umbraco.Tests.TestHelpers
});
}
protected virtual IUmbracoSettingsSection UmbracoSettings { get; private set; }
/// <summary>
/// By default this returns false which means the plugin manager will not be reset so it doesn't need to re-scan

View File

@@ -0,0 +1,34 @@
using NUnit.Framework;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Tests.TestHelpers
{
/// <summary>
/// A base test class that ensures that the umbraco configuration is mocked
/// </summary>
[TestFixture]
public abstract class BaseUmbracoConfigurationTest
{
[SetUp]
public virtual void Initialize()
{
TestHelper.SetupLog4NetForTests();
//mock the Umbraco settings that we need
var settings = SettingsForTests.GetMockSettings();
//sets the global singleton to use the mocked format
SettingsForTests.ConfigureSettings(settings);
//set our local variable for tests to use (preferably)
UmbracoSettings = settings;
}
[TearDown]
public virtual void TearDown()
{
//reset settings
SettingsForTests.Reset();
}
protected virtual IUmbracoSettingsSection UmbracoSettings { get; private set; }
}
}

View File

@@ -379,6 +379,7 @@
<Compile Include="Publishing\PublishingStrategyTests.cs" />
<Compile Include="Resolvers\ActionsResolverTests.cs" />
<Compile Include="AsynchronousRollingFileAppenderTests.cs" />
<Compile Include="TestHelpers\BaseUmbracoConfigurationTest.cs" />
<Compile Include="TestHelpers\Entities\MockedMember.cs" />
<Compile Include="TestHelpers\Entities\MockedUser.cs" />
<Compile Include="TestHelpers\Entities\MockedUserType.cs" />