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

58 lines
2.1 KiB
C#
Raw Normal View History

2018-06-29 19:52:40 +02:00
using Umbraco.Core;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.PropertyEditors.ValueConverters;
using Umbraco.Tests.TestHelpers;
using Moq;
2018-07-20 16:39:39 +02:00
using Umbraco.Core.Composing;
2018-06-29 19:52:40 +02:00
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Web.PropertyEditors;
namespace Umbraco.Tests.PublishedContent
{
/// <summary>
/// Abstract base class for tests for published content and published media
/// </summary>
public abstract class PublishedContentTestBase : BaseWebTest
{
protected override void Compose()
{
base.Compose();
// FIXME: what about the if (PropertyValueConvertersResolver.HasCurrent == false) ??
2018-06-29 19:52:40 +02:00
// can we risk double - registering and then, what happens?
2018-11-28 17:35:12 +01:00
Composition.WithCollectionBuilder<PropertyValueConverterCollectionBuilder>()
.Clear()
2018-06-29 19:52:40 +02:00
.Append<DatePickerValueConverter>()
.Append<TinyMceValueConverter>()
.Append<YesNoValueConverter>();
}
protected override void Initialize()
{
base.Initialize();
2018-11-28 12:59:40 +01:00
var converters = Factory.GetInstance<PropertyValueConverterCollection>();
2018-06-29 19:52:40 +02:00
var dataTypeService = new TestObjects.TestDataTypeService(
new DataType(new RichTextPropertyEditor(Mock.Of<ILogger>())) { Id = 1 });
var publishedContentTypeFactory = new PublishedContentTypeFactory(Mock.Of<IPublishedModelFactory>(), converters, dataTypeService);
// need to specify a custom callback for unit tests
var propertyTypes = new[]
{
// AutoPublishedContentType will auto-generate other properties
publishedContentTypeFactory.CreatePropertyType("content", 1),
};
var type = new AutoPublishedContentType(0, "anything", propertyTypes);
ContentTypesCache.GetPublishedContentTypeByAlias = alias => type;
var umbracoContext = GetUmbracoContext("/test");
Umbraco.Web.Composing.Current.UmbracoContextAccessor.UmbracoContext = umbracoContext;
}
}
}