From 62be1b126761c333c431fc07d2c863bbfd848e48 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Thu, 21 Feb 2013 20:42:49 +0600 Subject: [PATCH 1/3] un-ignores Can_Get_File_Dates in AbstractFileSystemTests... not sure why it was ignored seems to work properly. --- src/Umbraco.Tests/IO/AbstractFileSystemTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Umbraco.Tests/IO/AbstractFileSystemTests.cs b/src/Umbraco.Tests/IO/AbstractFileSystemTests.cs index 16e0a106b4..a818070ef8 100644 --- a/src/Umbraco.Tests/IO/AbstractFileSystemTests.cs +++ b/src/Umbraco.Tests/IO/AbstractFileSystemTests.cs @@ -105,7 +105,6 @@ namespace Umbraco.Tests.IO _fileSystem.DeleteDirectory("test", true); } - [Ignore] [Test] public void Can_Get_File_Dates() { From 0b74164a8e9730c774b601eccde296d0b1c29586 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Thu, 21 Feb 2013 21:01:00 +0600 Subject: [PATCH 2/3] New base test class for anything relating to published content/media, un-ignores strongly typed tests. --- .../ContentStores/PublishMediaStoreTests.cs | 7 +-- .../DynamicDocumentTestsBase.cs | 2 +- .../DynamicPublishedContentTests.cs | 36 +----------- .../PublishedContentTestBase.cs | 57 +++++++++++++++++++ .../PublishedContent/PublishedContentTests.cs | 30 +--------- .../PublishedContent/PublishedMediaTests.cs | 54 ++---------------- .../StronglyTypedQueryTests.cs | 19 ++++++- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 + 8 files changed, 84 insertions(+), 122 deletions(-) create mode 100644 src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs diff --git a/src/Umbraco.Tests/ContentStores/PublishMediaStoreTests.cs b/src/Umbraco.Tests/ContentStores/PublishMediaStoreTests.cs index d1a1997ac9..61713e43bd 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(); } [Test] 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 bf3a410e51..cb7bb0d11f 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 { @@ -62,38 +62,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 c37cd0cf18..75868e373d 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 d1d3266189..45ef120481 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.Tests.TestHelpers; using Umbraco.Web; @@ -11,8 +12,20 @@ using Umbraco.Web; namespace Umbraco.Tests.PublishedContent { [TestFixture] - public class StronglyTypedQueryTests : BaseWebTest + 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; } @@ -69,7 +82,7 @@ namespace Umbraco.Tests.PublishedContent return doc; } - [Ignore] + [Test] public void Type_Test() { @@ -79,7 +92,7 @@ namespace Umbraco.Tests.PublishedContent Assert.AreEqual("John Smith", result[1].ArticleAuthor); } - [Ignore] + [Test] public void As_Test() { diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index e9c23eb182..fbeaabf9a1 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -68,6 +68,7 @@ + From 1aa137e9daf3daf7462710d63965dfb8eaa6633e Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Thu, 21 Feb 2013 21:13:21 +0600 Subject: [PATCH 3/3] merge fix --- .../PublishedContent/StronglyTypedQueryTests.cs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs b/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs index 2bfcfb4c54..7355544256 100644 --- a/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs +++ b/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs @@ -33,22 +33,6 @@ namespace Umbraco.Tests.PublishedContent 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 @"