2013-02-21 21:01:00 +06:00
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2013-09-05 17:47:13 +02:00
|
|
|
using System.Linq;
|
2013-02-21 21:01:00 +06:00
|
|
|
using Umbraco.Core;
|
|
|
|
|
using Umbraco.Core.Configuration;
|
2013-09-05 17:47:13 +02:00
|
|
|
using Umbraco.Core.Models;
|
|
|
|
|
using Umbraco.Core.Models.PublishedContent;
|
2013-02-21 21:01:00 +06:00
|
|
|
using Umbraco.Core.PropertyEditors;
|
|
|
|
|
using Umbraco.Tests.TestHelpers;
|
|
|
|
|
using Umbraco.Web;
|
2013-02-05 06:31:13 -01:00
|
|
|
using Umbraco.Web.PublishedCache;
|
2013-03-22 15:02:26 -01:00
|
|
|
using Umbraco.Web.PublishedCache.XmlPublishedCache;
|
2013-02-21 21:01:00 +06:00
|
|
|
|
|
|
|
|
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();
|
2013-04-01 23:30:19 +06:00
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
// need to specify a custom callback for unit tests
|
|
|
|
|
var propertyTypes = new[]
|
2013-02-21 21:01:00 +06:00
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
// AutoPublishedContentType will auto-generate other properties
|
|
|
|
|
new PublishedPropertyType("content", Guid.Parse(Constants.PropertyEditors.TinyMCEv3), 0, 0),
|
2013-02-21 21:01:00 +06:00
|
|
|
};
|
2013-09-05 17:47:13 +02:00
|
|
|
var type = new AutoPublishedContentType(0, "anything", propertyTypes);
|
|
|
|
|
PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;
|
2013-02-21 21:01:00 +06:00
|
|
|
|
|
|
|
|
var rCtx = GetRoutingContext("/test", 1234);
|
|
|
|
|
UmbracoContext.Current = rCtx.UmbracoContext;
|
2013-02-21 21:33:21 +06:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void FreezeResolution()
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver(
|
2013-02-21 21:33:21 +06:00
|
|
|
new[]
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
typeof(DatePickerValueConverter),
|
|
|
|
|
typeof(TinyMceValueConverter),
|
|
|
|
|
typeof(YesNoValueConverter)
|
2013-02-21 21:33:21 +06:00
|
|
|
});
|
|
|
|
|
|
2013-03-31 18:40:55 -02:00
|
|
|
PublishedCachesResolver.Current = new PublishedCachesResolver(new PublishedCaches(
|
|
|
|
|
new PublishedContentCache(), new PublishedMediaCache()));
|
2013-02-21 21:33:21 +06:00
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
if (PublishedContentModelFactoryResolver.HasCurrent == false)
|
|
|
|
|
PublishedContentModelFactoryResolver.Current = new PublishedContentModelFactoryResolver();
|
|
|
|
|
|
2013-02-21 21:33:21 +06:00
|
|
|
base.FreezeResolution();
|
2013-02-21 21:01:00 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void TearDown()
|
|
|
|
|
{
|
|
|
|
|
base.TearDown();
|
2013-03-13 18:31:07 +04:00
|
|
|
|
2013-02-21 21:01:00 +06:00
|
|
|
UmbracoContext.Current = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|