diff --git a/src/Umbraco.Tests/ContentStores/PublishMediaStoreTests.cs b/src/Umbraco.Tests/ContentStores/PublishMediaStoreTests.cs index 98ae8afca6..349f24a2fa 100644 --- a/src/Umbraco.Tests/ContentStores/PublishMediaStoreTests.cs +++ b/src/Umbraco.Tests/ContentStores/PublishMediaStoreTests.cs @@ -15,7 +15,7 @@ using umbraco.BusinessLogic; namespace Umbraco.Tests.ContentStores { [TestFixture] - public class PublishMediaStoreTests : BaseWebTest + public class PublishMediaStoreTests : PublishedContentTestBase { public override void Initialize() { @@ -30,16 +30,11 @@ namespace Umbraco.Tests.ContentStores Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"), true); - Core.Configuration.UmbracoSettings.SettingsFilePath = Core.IO.IOHelper.MapPath(Core.IO.SystemDirectories.Config + Path.DirectorySeparatorChar, false); - - //we're going to use the same initialization as the PublishedMediaTests - PublishedMediaTests.DoInitialization(GetUmbracoContext("/test", 1234)); } public override void TearDown() { base.TearDown(); - PublishedMediaTests.DoTearDown(); } [Ignore] diff --git a/src/Umbraco.Tests/IO/AbstractFileSystemTests.cs b/src/Umbraco.Tests/IO/AbstractFileSystemTests.cs index 17caa76dfc..c48cee58d7 100644 --- a/src/Umbraco.Tests/IO/AbstractFileSystemTests.cs +++ b/src/Umbraco.Tests/IO/AbstractFileSystemTests.cs @@ -110,7 +110,6 @@ namespace Umbraco.Tests.IO _fileSystem.DeleteDirectory("test", true); } - [Ignore] [Test] public void Can_Get_File_Dates() { diff --git a/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs b/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs index fc63ef4c39..ac4b322aac 100644 --- a/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs +++ b/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs @@ -11,7 +11,7 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.PublishedContent { [TestFixture] - public abstract class DynamicDocumentTestsBase : BaseRoutingTest + public abstract class DynamicDocumentTestsBase : PublishedContentTestBase { public override void Initialize() { diff --git a/src/Umbraco.Tests/PublishedContent/DynamicPublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/DynamicPublishedContentTests.cs index 40049d8d2f..8fc3d880c1 100644 --- a/src/Umbraco.Tests/PublishedContent/DynamicPublishedContentTests.cs +++ b/src/Umbraco.Tests/PublishedContent/DynamicPublishedContentTests.cs @@ -1,56 +1,22 @@ -using System; -using System.IO; using System.Linq; using NUnit.Framework; -using Umbraco.Core; -using Umbraco.Core.Configuration; using Umbraco.Core.Models; -using Umbraco.Core.PropertyEditors; using Umbraco.Web; using Umbraco.Web.Models; namespace Umbraco.Tests.PublishedContent { - [TestFixture] + [TestFixture] public class DynamicPublishedContentTests : DynamicDocumentTestsBase { public override void Initialize() { base.Initialize(); - - PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver( - new[] - { - typeof(DatePickerPropertyEditorValueConverter), - typeof(TinyMcePropertyEditorValueConverter), - typeof(YesNoPropertyEditorValueConverter) - }); - - 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("5e9b75ae-face-41c8-b47e-5f4b0fd82f83"); - } - return Guid.Empty; - }; - - var rCtx = GetRoutingContext("/test", 1234); - UmbracoContext.Current = rCtx.UmbracoContext; - PublishedContentStoreResolver.Current = new PublishedContentStoreResolver(new DefaultPublishedContentStore()); } public override void TearDown() { base.TearDown(); - - PropertyEditorValueConvertersResolver.Reset(); - PublishedContentStoreResolver.Reset(); - UmbracoContext.Current = null; } internal DynamicPublishedContent GetNode(int id) diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs new file mode 100644 index 0000000000..311cb1f391 --- /dev/null +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs @@ -0,0 +1,57 @@ +using System; +using System.IO; +using Umbraco.Core; +using Umbraco.Core.Configuration; +using Umbraco.Core.PropertyEditors; +using Umbraco.Tests.TestHelpers; +using Umbraco.Web; + +namespace Umbraco.Tests.PublishedContent +{ + /// + /// Abstract base class for tests for published content and published media + /// + public abstract class PublishedContentTestBase : BaseRoutingTest + { + public override void Initialize() + { + base.Initialize(); + + UmbracoSettings.SettingsFilePath = Core.IO.IOHelper.MapPath(Core.IO.SystemDirectories.Config + Path.DirectorySeparatorChar, false); + + PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver( + new[] + { + typeof(DatePickerPropertyEditorValueConverter), + typeof(TinyMcePropertyEditorValueConverter), + typeof(YesNoPropertyEditorValueConverter) + }); + + //need to specify a custom callback for unit tests + PublishedContentHelper.GetDataTypeCallback = (docTypeAlias, propertyAlias) => + { + if (propertyAlias == "content") + { + //return the rte type id + return Guid.Parse("5e9b75ae-face-41c8-b47e-5f4b0fd82f83"); + } + return Guid.Empty; + }; + + var rCtx = GetRoutingContext("/test", 1234); + UmbracoContext.Current = rCtx.UmbracoContext; + PublishedContentStoreResolver.Current = new PublishedContentStoreResolver(new DefaultPublishedContentStore()); + PublishedMediaStoreResolver.Current = new PublishedMediaStoreResolver(new DefaultPublishedMediaStore()); + } + + public override void TearDown() + { + base.TearDown(); + + PropertyEditorValueConvertersResolver.Reset(); + PublishedContentStoreResolver.Reset(); + PublishedMediaStoreResolver.Reset(); + UmbracoContext.Current = null; + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs index d2570dacfd..9f652e4c22 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs @@ -14,7 +14,7 @@ namespace Umbraco.Tests.PublishedContent /// Tests the methods on IPublishedContent using the DefaultPublishedContentStore /// [TestFixture] - public class PublishedContentTests : BaseWebTest + public class PublishedContentTests : PublishedContentTestBase { protected override bool RequiresDbSetup { @@ -65,38 +65,12 @@ namespace Umbraco.Tests.PublishedContent public override void Initialize() { base.Initialize(); - - PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver( - new[] - { - typeof(DatePickerPropertyEditorValueConverter), - typeof(TinyMcePropertyEditorValueConverter), - typeof(YesNoPropertyEditorValueConverter) - }); - - //need to specify a custom callback for unit tests - PublishedContentHelper.GetDataTypeCallback = (docTypeAlias, propertyAlias) => - { - if (propertyAlias == "content") - { - //return the rte type id - return Guid.Parse("5e9b75ae-face-41c8-b47e-5f4b0fd82f83"); - } - return Guid.Empty; - }; - - var umbCtx = GetUmbracoContext("/test", 1234); - UmbracoContext.Current = umbCtx; - PublishedContentStoreResolver.Current = new PublishedContentStoreResolver(new DefaultPublishedContentStore()); } public override void TearDown() { base.TearDown(); - - PropertyEditorValueConvertersResolver.Reset(); - PublishedContentStoreResolver.Reset(); - UmbracoContext.Current = null; + } internal IPublishedContent GetNode(int id) diff --git a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs index eeb7cb4022..800d6dbb0d 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs @@ -28,64 +28,20 @@ namespace Umbraco.Tests.PublishedContent /// Tests the typed extension methods on IPublishedContent using the DefaultPublishedMediaStore /// [TestFixture] - public class PublishedMediaTests : BaseWebTest + public class PublishedMediaTests : PublishedContentTestBase { public override void Initialize() { base.Initialize(); - DoInitialization(GetUmbracoContext("/test", 1234)); + UmbracoSettings.ForceSafeAliases = true; + UmbracoSettings.UmbracoLibraryCacheDuration = 1800; + UmbracoSettings.ForceSafeAliases = true; } - - /// - /// Shared with PublishMediaStoreTests - /// - /// - internal static void DoInitialization(UmbracoContext umbContext) - { - PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver( - new[] - { - typeof(DatePickerPropertyEditorValueConverter), - typeof(TinyMcePropertyEditorValueConverter), - typeof(YesNoPropertyEditorValueConverter) - }); - - //need to specify a custom callback for unit tests - PublishedContentHelper.GetDataTypeCallback = (docTypeAlias, propertyAlias) => - { - if (propertyAlias == "content") - { - //return the rte type id - return Guid.Parse("5e9b75ae-face-41c8-b47e-5f4b0fd82f83"); - } - return Guid.Empty; - }; - - UmbracoSettings.ForceSafeAliases = true; - UmbracoSettings.UmbracoLibraryCacheDuration = 1800; - - UmbracoContext.Current = umbContext; - PublishedMediaStoreResolver.Current = new PublishedMediaStoreResolver(new DefaultPublishedMediaStore()); - - UmbracoSettings.ForceSafeAliases = true; - } - + public override void TearDown() { base.TearDown(); - - DoTearDown(); - } - - /// - /// Shared with PublishMediaStoreTests - /// - internal static void DoTearDown() - { - PropertyEditorValueConvertersResolver.Reset(); - UmbracoContext.Current = null; - PublishedMediaStoreResolver.Reset(); } /// diff --git a/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs b/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs index 5053279617..7355544256 100644 --- a/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs +++ b/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs @@ -4,6 +4,7 @@ using System.Collections.ObjectModel; using System.Linq; using NUnit.Framework; using Umbraco.Core; +using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; using Umbraco.Tests.TestHelpers; @@ -13,29 +14,25 @@ using Umbraco.Web.Routing; namespace Umbraco.Tests.PublishedContent { [TestFixture] - public class StronglyTypedQueryTests : BaseRoutingTest + public class StronglyTypedQueryTests : PublishedContentTestBase { + public override void Initialize() + { + base.Initialize(); + UmbracoSettings.UseLegacyXmlSchema = false; + } + + public override void TearDown() + { + base.TearDown(); + UmbracoSettings.ResetSetters(); + } + protected override bool RequiresDbSetup { get { return false; } } - public override void Initialize() - { - base.Initialize(); - - var routingCtx = GetRoutingContext("/test", 1234); - UmbracoContext.Current = routingCtx.UmbracoContext; - PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver(Enumerable.Empty()); - } - - public override void TearDown() - { - base.TearDown(); - UmbracoContext.Current = null; - PropertyEditorValueConvertersResolver.Reset(); - } - protected override string GetXmlContent(int templateId) { return @" @@ -87,6 +84,7 @@ namespace Umbraco.Tests.PublishedContent return doc; } + [Test] public void Type_Test() { @@ -96,6 +94,7 @@ namespace Umbraco.Tests.PublishedContent Assert.AreEqual("John Smith", result[1].ArticleAuthor); } + [Test] public void As_Test() { diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 497befe86d..4ddd2dc0a8 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -190,6 +190,7 @@ +