Files
Umbraco-CMS/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs

63 lines
2.2 KiB
C#
Raw Normal View History

using System;
using System.IO;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.PropertyEditors;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web;
2013-02-05 06:31:13 -01:00
using Umbraco.Web.PublishedCache;
using Umbraco.Web.PublishedCache.LegacyXmlCache;
namespace Umbraco.Tests.PublishedContent
{
/// <summary>
/// Abstract base class for tests for published content and published media
/// </summary>
public abstract class PublishedContentTestBase : BaseRoutingTest
{
public override void Initialize()
{
base.Initialize();
UmbracoSettings.SettingsFilePath = Core.IO.IOHelper.MapPath(Core.IO.SystemDirectories.Config + Path.DirectorySeparatorChar, false);
//need to specify a custom callback for unit tests
PublishedContentHelper.GetDataTypeCallback = (docTypeAlias, propertyAlias) =>
{
if (propertyAlias == "content")
{
//return the rte type id
return Guid.Parse(Constants.PropertyEditors.TinyMCEv3);
}
return Guid.Empty;
};
var rCtx = GetRoutingContext("/test", 1234);
UmbracoContext.Current = rCtx.UmbracoContext;
2013-02-21 21:33:21 +06:00
}
protected override void FreezeResolution()
{
PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver(
new[]
{
typeof(DatePickerPropertyEditorValueConverter),
typeof(TinyMcePropertyEditorValueConverter),
typeof(YesNoPropertyEditorValueConverter)
});
2013-02-05 06:31:13 -01:00
PublishedContentCacheResolver.Current = new PublishedContentCacheResolver(new PublishedContentCache());
PublishedMediaCacheResolver.Current = new PublishedMediaCacheResolver(new PublishedMediaCache());
2013-02-21 21:33:21 +06:00
base.FreezeResolution();
}
public override void TearDown()
{
base.TearDown();
UmbracoContext.Current = null;
}
}
}