Fixes unit tests using the ContentService.Save method. Because we are using .ToXml in the save method to save preview xml we need to setup the DataTypesResolver in the test setup.

This commit is contained in:
Morten Christensen
2013-01-30 16:23:33 -01:00
parent a82c5c332a
commit b20bb7a5a2
2 changed files with 40 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Linq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Caching;
using Umbraco.Core.Persistence.Querying;
@@ -8,6 +9,8 @@ using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.UnitOfWork;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.Entities;
using umbraco.editorControls.tinyMCE3;
using umbraco.interfaces;
namespace Umbraco.Tests.Persistence.Repositories
{
@@ -17,6 +20,20 @@ namespace Umbraco.Tests.Persistence.Repositories
[SetUp]
public override void Initialize()
{
//NOTE The DataTypesResolver is only necessary because we are using the Save method in the ContentService
//this ensures its reset
PluginManager.Current = new PluginManager();
//for testing, we'll specify which assemblies are scanned for the PluginTypeResolver
PluginManager.Current.AssembliesToScan = new[]
{
typeof(IDataType).Assembly,
typeof(tinyMCE3dataType).Assembly
};
DataTypesResolver.Current = new DataTypesResolver(
PluginManager.Current.ResolveDataTypes());
base.Initialize();
CreateTestData();
@@ -237,6 +254,9 @@ namespace Umbraco.Tests.Persistence.Repositories
[TearDown]
public override void TearDown()
{
//reset the app context
DataTypesResolver.Reset();
base.TearDown();
}