diff --git a/src/Umbraco.Tests/Models/Mapping/AutoMapperTests.cs b/src/Umbraco.Tests/Models/Mapping/AutoMapperTests.cs index 2658c38d4e..396bbff8eb 100644 --- a/src/Umbraco.Tests/Models/Mapping/AutoMapperTests.cs +++ b/src/Umbraco.Tests/Models/Mapping/AutoMapperTests.cs @@ -13,8 +13,8 @@ using Umbraco.Tests.Testing; namespace Umbraco.Tests.Models.Mapping { [TestFixture] - [UmbracoTest(AutoMapper = true)] - public class AutoMapperTests : TestWithApplicationBase + [UmbracoTest(WithApplication = true)] + public class AutoMapperTests : UmbracoTestBase { protected override void Compose() { diff --git a/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs b/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs index 73192ff1ae..65f257329d 100644 --- a/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs +++ b/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs @@ -5,14 +5,13 @@ using AutoMapper; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Cache; using Umbraco.Core.DI; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Services; -using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; +using Umbraco.Tests.Testing; using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.Mapping; using Umbraco.Web.PropertyEditors; @@ -20,7 +19,8 @@ using Umbraco.Web.PropertyEditors; namespace Umbraco.Tests.Models.Mapping { [TestFixture] - public class ContentTypeModelMappingTests : TestWithApplicationBase + [UmbracoTest(WithApplication = true)] + public class ContentTypeModelMappingTests : UmbracoTestBase { // mocks of services that can be setup on a test by test basis to return whatever we want private readonly Mock _contentTypeService = new Mock(); diff --git a/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs b/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs index fcc1e6007d..a4880bd656 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs @@ -1,22 +1,18 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Linq; using NUnit.Framework; using Umbraco.Core.IO; using Umbraco.Core.Models; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Core.PropertyEditors; -using Umbraco.Tests.TestHelpers; using Umbraco.Core.DI; +using Umbraco.Tests.Testing; namespace Umbraco.Tests.Persistence.Repositories { [TestFixture] - public class PartialViewRepositoryTests : TestWithApplicationBase + [UmbracoTest(WithApplication = true)] + public class PartialViewRepositoryTests : UmbracoTestBase { private IFileSystem _fileSystem; diff --git a/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs index d90075bbf5..cd9d9ef59b 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs @@ -7,16 +7,16 @@ using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.DI; using Umbraco.Core.IO; using Umbraco.Core.Models; -using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Core.PropertyEditors; -using Umbraco.Tests.TestHelpers; +using Umbraco.Tests.Testing; namespace Umbraco.Tests.Persistence.Repositories { [TestFixture] - public class ScriptRepositoryTest : TestWithApplicationBase + [UmbracoTest(WithApplication = true)] + public class ScriptRepositoryTest : UmbracoTestBase { private IFileSystem _fileSystem; diff --git a/src/Umbraco.Tests/Security/BackOfficeCookieManagerTests.cs b/src/Umbraco.Tests/Security/BackOfficeCookieManagerTests.cs index 83c21b105a..1ee031ba83 100644 --- a/src/Umbraco.Tests/Security/BackOfficeCookieManagerTests.cs +++ b/src/Umbraco.Tests/Security/BackOfficeCookieManagerTests.cs @@ -6,8 +6,7 @@ using Microsoft.Owin; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Configuration.UmbracoSettings; -using Umbraco.Tests.TestHelpers; +using Umbraco.Tests.Testing; using Umbraco.Web; using Umbraco.Web.PublishedCache; using Umbraco.Web.Routing; @@ -17,7 +16,8 @@ using Umbraco.Web.Security.Identity; namespace Umbraco.Tests.Security { [TestFixture] - public class BackOfficeCookieManagerTests : TestWithApplicationBase + [UmbracoTest(WithApplication = true)] + public class BackOfficeCookieManagerTests : UmbracoTestBase { [Test] public void ShouldAuthenticateRequest_When_Not_Configured() diff --git a/src/Umbraco.Tests/Services/ContentTypeServiceExtensionsTests.cs b/src/Umbraco.Tests/Services/ContentTypeServiceExtensionsTests.cs index 6779c523f8..ba4485638e 100644 --- a/src/Umbraco.Tests/Services/ContentTypeServiceExtensionsTests.cs +++ b/src/Umbraco.Tests/Services/ContentTypeServiceExtensionsTests.cs @@ -5,13 +5,14 @@ using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Services; -using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; +using Umbraco.Tests.Testing; namespace Umbraco.Tests.Services { [TestFixture] - public class ContentTypeServiceExtensionsTests : TestWithApplicationBase + [UmbracoTest(WithApplication = true)] + public class ContentTypeServiceExtensionsTests : UmbracoTestBase { [Test] public void GetAvailableCompositeContentTypes_No_Overlap_By_Content_Type_And_Property_Type_Alias() diff --git a/src/Umbraco.Tests/TestHelpers/TestWithApplicationBase.cs b/src/Umbraco.Tests/TestHelpers/TestWithApplicationBase.cs deleted file mode 100644 index bb0eab321a..0000000000 --- a/src/Umbraco.Tests/TestHelpers/TestWithApplicationBase.cs +++ /dev/null @@ -1,151 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using Moq; -using NUnit.Framework; -using Umbraco.Core; -using Umbraco.Core.Cache; -using Umbraco.Core.IO; -using Umbraco.Core.Logging; -using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.SqlSyntax; -using Umbraco.Core.PropertyEditors; -using Umbraco.Core.Strings; -using Umbraco.Core.DI; -using Umbraco.Core.Persistence.Mappers; -using Umbraco.Core.Events; -using Umbraco.Core.Manifest; -using Umbraco.Core.Models.PublishedContent; -using Umbraco.Core.Persistence.Querying; -using Umbraco.Core.Plugins; -using Umbraco.Core.Services; -using Umbraco.Tests.TestHelpers.Stubs; -using Umbraco.Tests.Testing; -using Umbraco.Web.Services; -using UmbracoExamine; - -namespace Umbraco.Tests.TestHelpers -{ - /// - /// Provides a base class for all Umbraco tests that require the Umbraco application. - /// - /// - /// Sets the Umbraco application DI container. - /// Defines the Compose method for DI composition. - /// Sets all sorts of things such as logging, plugin manager, base services, database factory & context... - /// Does *not* create a database. - /// - [TestFixture] - [UmbracoTest(AutoMapper = true, ResetPluginManager = false)] - public abstract class TestWithApplicationBase : UmbracoTestBase - { - protected ILogger Logger => Container.GetInstance(); - - protected IProfiler Profiler => Container.GetInstance(); - - protected ProfilingLogger ProfilingLogger => Container.GetInstance(); - - protected CacheHelper CacheHelper => Container.GetInstance(); - - protected virtual ISqlSyntaxProvider SqlSyntax => new SqlCeSyntaxProvider(); - - protected IMapperCollection Mappers => Container.GetInstance(); - - protected IQueryFactory QueryFactory => Container.GetInstance().QueryFactory; - - /// - /// Gets a value indicating whether the plugin manager should be resetted before and after each test. - /// - /// - /// False by default, so the plugin manager does not need to re-scan all of the assemblies and tests run faster. - /// Can be overriden if the plugin manager does need to reset, usually when SetupPluginManager has been overriden. - /// - protected virtual bool PluginManagerResetRequired => false; - - public override void SetUp() - { - base.SetUp(); - - TestHelper.InitializeContentDirectories(); - - // initialize legacy mapings for core editors - // create the legacy prop-eds mapping - if (LegacyPropertyEditorIdToAliasConverter.Count() == 0) - LegacyPropertyEditorIdToAliasConverter.CreateMappingsForCoreEditors(); - } - - public override void TearDown() - { - base.TearDown(); - - TestHelper.CleanContentDirectories(); - TestHelper.CleanUmbracoSettingsConfig(); - } - - protected override void Compose() - { - base.Compose(); - - var settings = SettingsForTests.GetDefault(); - - // default Datalayer/Repositories/SQL/Database/etc... - Container.RegisterFrom(); - - // register basic stuff that might need to be there for some container resolvers to work - Container.RegisterSingleton(factory => SettingsForTests.GetDefault()); - Container.RegisterSingleton(factory => settings.Content); - Container.RegisterSingleton(factory => settings.Templates); - Container.Register(); - Container.Register(factory => new MediaFileSystem(Mock.Of())); - Container.RegisterSingleton(); - - // replace some stuff - Container.RegisterSingleton(factory => Mock.Of(), "ScriptFileSystem"); - Container.RegisterSingleton(factory => Mock.Of(), "PartialViewFileSystem"); - Container.RegisterSingleton(factory => Mock.Of(), "PartialViewMacroFileSystem"); - Container.RegisterSingleton(factory => Mock.Of(), "StylesheetFileSystem"); - - // need real file systems here as templates content is on-disk only - //Container.RegisterSingleton(factory => Mock.Of(), "MasterpageFileSystem"); - //Container.RegisterSingleton(factory => Mock.Of(), "ViewFileSystem"); - Container.RegisterSingleton(factory => new PhysicalFileSystem("Views", "/views"), "ViewFileSystem"); - Container.RegisterSingleton(factory => new PhysicalFileSystem("MasterPages", "/masterpages"), "MasterpageFileSystem"); - - // no factory (noop) - Container.RegisterSingleton(); - - // register application stuff (database factory & context, services...) - Container.RegisterCollectionBuilder() - .AddCore(); - - Container.RegisterSingleton(_ => new TransientEventMessagesFactory()); - Container.RegisterSingleton(); - var sqlSyntaxProviders = TestObjects.GetDefaultSqlSyntaxProviders(Logger); - Container.RegisterSingleton(_ => sqlSyntaxProviders.OfType().First()); - Container.RegisterSingleton(f => new UmbracoDatabaseFactory( - Core.Configuration.GlobalSettings.UmbracoConnectionName, - sqlSyntaxProviders, - Logger, f.GetInstance(), - Mock.Of())); - Container.RegisterSingleton(f => new DatabaseContext(f.GetInstance())); - - Container.RegisterCollectionBuilder(); // empty - Container.Register(factory - => TestObjects.GetDatabaseUnitOfWorkProvider(factory.GetInstance(), factory.TryGetInstance(), factory.TryGetInstance())); - - Container.RegisterFrom(); - // composition root is doing weird things, fix - Container.RegisterSingleton(); - Container.RegisterSingleton(); - - // somehow property editor ends up wanting this - Container.RegisterSingleton(f => new ManifestBuilder( - f.GetInstance(), - new ManifestParser(f.GetInstance(), new DirectoryInfo(IOHelper.MapPath("~/App_Plugins")), f.GetInstance()) - )); - - // note - don't register collections, use builders - Container.RegisterCollectionBuilder(); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs index c306a0ff9b..388fe1ce43 100644 --- a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs +++ b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Configuration; using System.Data.SqlServerCe; -using System.IO; using System.Linq; using System.Web.Routing; using System.Xml; @@ -13,9 +12,7 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.UmbracoSettings; -using Umbraco.Core.IO; using Umbraco.Core.Logging; -using Umbraco.Core.Manifest; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.SqlSyntax; using Umbraco.Core.Persistence.UnitOfWork; @@ -29,10 +26,7 @@ using Umbraco.Core.Plugins; using Umbraco.Web.Routing; using File = System.IO.File; using Umbraco.Core.DI; -using Umbraco.Core.Events; using Umbraco.Core.Persistence.Mappers; -using Umbraco.Core.Persistence.Querying; -using Umbraco.Core.Strings; using Umbraco.Tests.TestHelpers.Stubs; using Umbraco.Tests.Testing; @@ -47,8 +41,9 @@ namespace Umbraco.Tests.TestHelpers /// Provides an Umbraco context and Xml content. /// fixme what else? /// - [TestFixture, RequiresSTA] - public abstract class TestWithDatabaseBase : TestWithApplicationBase + [RequiresSTA] // why? + [UmbracoTest(WithApplication = true)] + public abstract class TestWithDatabaseBase : UmbracoTestBase { private CacheHelper _disabledCacheHelper; private IFacadeService _facadeService; diff --git a/src/Umbraco.Tests/Testing/UmbracoTestAttribute.cs b/src/Umbraco.Tests/Testing/UmbracoTestAttribute.cs index b70d667011..fd2d9b6493 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestAttribute.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestAttribute.cs @@ -8,20 +8,55 @@ namespace Umbraco.Tests.Testing [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, /*AllowMultiple = false,*/ Inherited = false)] public class UmbracoTestAttribute : Attribute { + #region Properties + + /// + /// Gets or sets a value indicating whether tests are "WithApplication". + /// + /// + /// Default is false. + /// This is for tests that inherited from TestWithApplicationBase. + /// Implies AutoMapper = true (, ResetPluginManager = false). + /// + public bool WithApplication { get { return _withApplication.ValueOrDefault(false); } set { _withApplication.Set(value); } } + private readonly Settable _withApplication = new Settable(); + + /// + /// Gets or sets a value indicating whether to compose and initialize AutoMapper. + /// + /// Default is false unless WithApplication is true, in which case default is true. + public bool AutoMapper { get { return _autoMapper.ValueOrDefault(WithApplication); } set { _autoMapper.Set(value);} } private readonly Settable _autoMapper = new Settable(); - public bool AutoMapper { get { return _autoMapper.ValueOrDefault(false); } set { _autoMapper.Set(value);} } - private readonly Settable _resetPluginManager = new Settable(); + /// + /// Gets or sets a value indicating ... FIXME to be completed + /// public bool ResetPluginManager { get { return _resetPluginManager.ValueOrDefault(false); } set { _resetPluginManager.Set(value); } } + private readonly Settable _resetPluginManager = new Settable(); - private readonly Settable _facadeServiceRepositoryEvents = new Settable(); + /// + /// Gets or sets a value indicating ... FIXME to be completed + /// public bool FacadeServiceRepositoryEvents { get { return _facadeServiceRepositoryEvents.ValueOrDefault(false); } set { _facadeServiceRepositoryEvents.Set(value); } } + private readonly Settable _facadeServiceRepositoryEvents = new Settable(); - private readonly Settable _logger = new Settable(); + /// + /// Gets or sets a value indicating the required logging support. + /// + /// Default is to mock logging. public UmbracoTestOptions.Logger Logger { get { return _logger.ValueOrDefault(UmbracoTestOptions.Logger.Mock); } set { _logger.Set(value); } } + private readonly Settable _logger = new Settable(); - private readonly Settable _database = new Settable(); + /// + /// Gets or sets a value indicating the required database support. + /// + /// Default is no database support. public UmbracoTestOptions.Database Database { get { return _database.ValueOrDefault(UmbracoTestOptions.Database.None); } set { _database.Set(value); } } + private readonly Settable _database = new Settable(); + + #endregion + + #region Get public static UmbracoTestAttribute Get(MethodInfo method) { @@ -56,5 +91,7 @@ namespace Umbraco.Tests.Testing _database.Set(other._database); return this; } + + #endregion } } diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index c65be1d6ca..813dea3d02 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -1,4 +1,6 @@ -using System.IO; +using System; +using System.IO; +using System.Linq; using System.Reflection; using AutoMapper; using LightInject; @@ -8,13 +10,26 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Components; using Umbraco.Core.DI; +using Umbraco.Core.Events; +using Umbraco.Core.IO; using Umbraco.Core.Logging; +using Umbraco.Core.Manifest; using Umbraco.Core.Models.Mapping; +using Umbraco.Core.Models.PublishedContent; +using Umbraco.Core.Persistence; +using Umbraco.Core.Persistence.Mappers; +using Umbraco.Core.Persistence.Querying; +using Umbraco.Core.Persistence.SqlSyntax; using Umbraco.Core.Plugins; +using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Services; +using Umbraco.Core.Strings; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Stubs; using Umbraco.Web; using Umbraco.Web.DI; +using Umbraco.Web.Services; +using UmbracoExamine; using Current = Umbraco.Core.DI.Current; namespace Umbraco.Tests.Testing @@ -39,6 +54,7 @@ namespace Umbraco.Tests.Testing // starting a test runs like this: // - SetUp() // when overriding, call base.SetUp() *first* then setup your own stuff // --- Compose() // when overriding, call base.Commpose() *first* then compose your own stuff + // --- Initialize() // same // - test runs // - TearDown() // when overriding, clear you own stuff *then* call base.TearDown() // @@ -64,6 +80,26 @@ namespace Umbraco.Tests.Testing private static PluginManager _pluginManager; + #region Accessors + + protected ILogger Logger => Container.GetInstance(); + + protected IProfiler Profiler => Container.GetInstance(); + + protected ProfilingLogger ProfilingLogger => Container.GetInstance(); + + protected CacheHelper CacheHelper => Container.GetInstance(); + + protected virtual ISqlSyntaxProvider SqlSyntax => Container.GetInstance(); + + protected IMapperCollection Mappers => Container.GetInstance(); + + protected IQueryFactory QueryFactory => Container.GetInstance().QueryFactory; + + #endregion + + #region Setup + [SetUp] public virtual void SetUp() { @@ -93,6 +129,7 @@ namespace Umbraco.Tests.Testing ComposeAutoMapper(Options.AutoMapper); ComposePluginManager(Options.ResetPluginManager); ComposeDatabase(Options.Database); + ComposeApplication(Options.WithApplication); // etc ComposeWtf(); @@ -107,9 +144,12 @@ namespace Umbraco.Tests.Testing protected virtual void Initialize() { InitializeAutoMapper(Options.AutoMapper); + InitializeApplication(Options.WithApplication); } - #region Composing + #endregion + + #region Compose protected virtual void ComposeLogging(UmbracoTestOptions.Logger option) { @@ -177,6 +217,72 @@ namespace Umbraco.Tests.Testing } + protected virtual void ComposeApplication(bool withApplication) + { + if (withApplication == false) return; + + var settings = SettingsForTests.GetDefault(); + + // default Datalayer/Repositories/SQL/Database/etc... + Container.RegisterFrom(); + + // register basic stuff that might need to be there for some container resolvers to work + Container.RegisterSingleton(factory => SettingsForTests.GetDefault()); + Container.RegisterSingleton(factory => settings.Content); + Container.RegisterSingleton(factory => settings.Templates); + Container.Register(); + Container.Register(factory => new MediaFileSystem(Mock.Of())); + Container.RegisterSingleton(); + + // replace some stuff + Container.RegisterSingleton(factory => Mock.Of(), "ScriptFileSystem"); + Container.RegisterSingleton(factory => Mock.Of(), "PartialViewFileSystem"); + Container.RegisterSingleton(factory => Mock.Of(), "PartialViewMacroFileSystem"); + Container.RegisterSingleton(factory => Mock.Of(), "StylesheetFileSystem"); + + // need real file systems here as templates content is on-disk only + //Container.RegisterSingleton(factory => Mock.Of(), "MasterpageFileSystem"); + //Container.RegisterSingleton(factory => Mock.Of(), "ViewFileSystem"); + Container.RegisterSingleton(factory => new PhysicalFileSystem("Views", "/views"), "ViewFileSystem"); + Container.RegisterSingleton(factory => new PhysicalFileSystem("MasterPages", "/masterpages"), "MasterpageFileSystem"); + + // no factory (noop) + Container.RegisterSingleton(); + + // register application stuff (database factory & context, services...) + Container.RegisterCollectionBuilder() + .AddCore(); + + Container.RegisterSingleton(_ => new TransientEventMessagesFactory()); + Container.RegisterSingleton(); + var sqlSyntaxProviders = TestObjects.GetDefaultSqlSyntaxProviders(Logger); + Container.RegisterSingleton(_ => sqlSyntaxProviders.OfType().First()); + Container.RegisterSingleton(f => new UmbracoDatabaseFactory( + Core.Configuration.GlobalSettings.UmbracoConnectionName, + sqlSyntaxProviders, + Logger, f.GetInstance(), + Mock.Of())); + Container.RegisterSingleton(f => new DatabaseContext(f.GetInstance())); + + Container.RegisterCollectionBuilder(); // empty + Container.Register(factory + => TestObjects.GetDatabaseUnitOfWorkProvider(factory.GetInstance(), factory.TryGetInstance(), factory.TryGetInstance())); + + Container.RegisterFrom(); + // composition root is doing weird things, fix + Container.RegisterSingleton(); + Container.RegisterSingleton(); + + // somehow property editor ends up wanting this + Container.RegisterSingleton(f => new ManifestBuilder( + f.GetInstance(), + new ManifestParser(f.GetInstance(), new DirectoryInfo(IOHelper.MapPath("~/App_Plugins")), f.GetInstance()) + )); + + // note - don't register collections, use builders + Container.RegisterCollectionBuilder(); + } + #endregion #region Initialize @@ -193,6 +299,18 @@ namespace Umbraco.Tests.Testing }); } + protected virtual void InitializeApplication(bool withApplication) + { + if (withApplication == false) return; + + TestHelper.InitializeContentDirectories(); + + // initialize legacy mapings for core editors + // create the legacy prop-eds mapping + if (LegacyPropertyEditorIdToAliasConverter.Count() == 0) + LegacyPropertyEditorIdToAliasConverter.CreateMappingsForCoreEditors(); + } + #endregion #region TearDown and Reset @@ -204,6 +322,12 @@ namespace Umbraco.Tests.Testing FirstTestInSession = false; Reset(); + + if (Options.WithApplication) + { + TestHelper.CleanContentDirectories(); + TestHelper.CleanUmbracoSettingsConfig(); + } } protected virtual void Reset() diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index d6b9a62085..c63c8babb4 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -529,7 +529,6 @@ - diff --git a/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs b/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs index 8639e591da..9246ac5940 100644 --- a/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs +++ b/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs @@ -13,6 +13,7 @@ using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Services; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Stubs; +using Umbraco.Tests.Testing; using Umbraco.Web; using Umbraco.Web.Mvc; using Umbraco.Web.PublishedCache; @@ -22,7 +23,8 @@ using Umbraco.Web.Security; namespace Umbraco.Tests.Web.Mvc { [TestFixture] - public class SurfaceControllerTests : TestWithApplicationBase + [UmbracoTest(WithApplication = true)] + public class SurfaceControllerTests : UmbracoTestBase { public override void SetUp() { diff --git a/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs b/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs index 1709a267ae..499e2acd48 100644 --- a/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs +++ b/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs @@ -16,6 +16,7 @@ using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Tests.TestHelpers; +using Umbraco.Tests.Testing; using Umbraco.Web; using Umbraco.Web.Models; using Umbraco.Web.Mvc; @@ -26,7 +27,8 @@ using Umbraco.Web.Security; namespace Umbraco.Tests.Web.Mvc { [TestFixture] - public class UmbracoViewPageTests : TestWithApplicationBase + [UmbracoTest(WithApplication = true)] + public class UmbracoViewPageTests : UmbracoTestBase { private FacadeService _service; diff --git a/src/Umbraco.Tests/Web/WebExtensionMethodTests.cs b/src/Umbraco.Tests/Web/WebExtensionMethodTests.cs index 0de68f6a38..fd2feed5a9 100644 --- a/src/Umbraco.Tests/Web/WebExtensionMethodTests.cs +++ b/src/Umbraco.Tests/Web/WebExtensionMethodTests.cs @@ -5,9 +5,8 @@ using System.Web.Mvc; using System.Web.Routing; using Moq; using NUnit.Framework; -using Umbraco.Core.Configuration.UmbracoSettings; -using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Stubs; +using Umbraco.Tests.Testing; using Umbraco.Web; using Umbraco.Web.Mvc; using Umbraco.Web.PublishedCache; @@ -18,7 +17,8 @@ using Current = Umbraco.Web.Current; namespace Umbraco.Tests.Web { [TestFixture] - public class WebExtensionMethodTests : TestWithApplicationBase + [UmbracoTest(WithApplication = true)] + public class WebExtensionMethodTests : UmbracoTestBase { [Test] public void RouteDataExtensions_GetUmbracoContext()