diff --git a/src/Umbraco.Core/Components/BootLoader.cs b/src/Umbraco.Core/Components/BootLoader.cs
index f83575a01e..b21bd2f356 100644
--- a/src/Umbraco.Core/Components/BootLoader.cs
+++ b/src/Umbraco.Core/Components/BootLoader.cs
@@ -12,7 +12,7 @@ namespace Umbraco.Core.Components
internal class BootLoader
{
- private readonly ServiceContainer _container;
+ private readonly IServiceContainer _container;
private readonly ProfilingLogger _proflog;
private IUmbracoComponent[] _components;
private bool _booted;
@@ -23,7 +23,7 @@ namespace Umbraco.Core.Components
/// Initializes a new instance of the class.
///
/// The application container.
- public BootLoader(ServiceContainer container)
+ public BootLoader(IServiceContainer container)
{
if (container == null) throw new ArgumentNullException(nameof(container));
_container = container;
diff --git a/src/Umbraco.Core/Components/Composition.cs b/src/Umbraco.Core/Components/Composition.cs
index 844b5b0267..a57eeeb417 100644
--- a/src/Umbraco.Core/Components/Composition.cs
+++ b/src/Umbraco.Core/Components/Composition.cs
@@ -17,7 +17,7 @@ namespace Umbraco.Core.Components
///
/// A container.
/// The runtime level.
- public Composition(ServiceContainer container, RuntimeLevel level)
+ public Composition(IServiceContainer container, RuntimeLevel level)
{
Container = container;
RuntimeLevel = level;
@@ -27,7 +27,7 @@ namespace Umbraco.Core.Components
/// Gets the container.
///
/// Use with care!
- public ServiceContainer Container { get; }
+ public IServiceContainer Container { get; }
///
/// Gets the runtime level.
diff --git a/src/Umbraco.Core/Persistence/Repositories/RecycleBinRepository.cs b/src/Umbraco.Core/Persistence/Repositories/RecycleBinRepository.cs
index 8df1496d2f..7dc04f2681 100644
--- a/src/Umbraco.Core/Persistence/Repositories/RecycleBinRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/RecycleBinRepository.cs
@@ -1,10 +1,8 @@
-using System;
using System.Collections.Generic;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.EntityBase;
-using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence.Mappers;
using Umbraco.Core.Persistence.UnitOfWork;
@@ -25,32 +23,5 @@ namespace Umbraco.Core.Persistence.Repositories
{
return GetByQuery(Query.Where(entity => entity.Trashed));
}
-
- ///
- /// Gets a list of files, which are referenced on items in the Recycle Bin.
- /// The list is generated by the convention that a file is referenced by
- /// the Upload data type or a property type with the alias 'umbracoFile'.
- ///
- ///
- ///
- /// This is purely for backwards compatibility
- ///
- internal List GetFilesInRecycleBinForUploadField()
- {
- //Issue query to get all trashed content or media that has the Upload field as a property
- //The value for each field is stored in a list: FilesToDelete()
- //Alias: Constants.Conventions.Media.File and PropertyEditorAlias: Constants.PropertyEditors.UploadField
- var sql = Sql()
- .Select("DISTINCT(dataNvarchar)")
- .From()
- .InnerJoin().On(left => left.NodeId, right => right.NodeId)
- .InnerJoin().On(left => left.PropertyTypeId, right => right.Id)
- .InnerJoin().On(left => left.DataTypeId, right => right.DataTypeId)
- .Where("umbracoNode.trashed = '1' AND umbracoNode.nodeObjectType = @NodeObjectType AND dataNvarchar IS NOT NULL AND (cmsPropertyType.Alias = @FileAlias OR cmsDataType.propertyEditorAlias = @PropertyEditorAlias)",
- new { FileAlias = Constants.Conventions.Media.File, NodeObjectType = NodeObjectTypeId, PropertyEditorAlias = Constants.PropertyEditors.UploadFieldAlias });
-
- var files = Database.Fetch(sql);
- return files;
- }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/UmbracoApplicationBase.cs b/src/Umbraco.Core/UmbracoApplicationBase.cs
index 86cd46e03c..b26d520730 100644
--- a/src/Umbraco.Core/UmbracoApplicationBase.cs
+++ b/src/Umbraco.Core/UmbracoApplicationBase.cs
@@ -70,6 +70,15 @@ namespace Umbraco.Core
container.RegisterInstance(logger);
// now it is ok to use Current.Logger
+ ConfigureUnhandledException(logger);
+
+ // get runtime & boot
+ _runtime = GetRuntime();
+ _runtime.Boot(container);
+ }
+
+ protected virtual void ConfigureUnhandledException(ILogger logger)
+ {
// take care of unhandled exceptions - there is nothing we can do to
// prevent the entire w3wp process to go down but at least we can try
// and log the exception
@@ -83,10 +92,6 @@ namespace Umbraco.Core
msg += ".";
logger.Error(msg, exception);
};
-
- // get runtime & boot
- _runtime = GetRuntime();
- _runtime.Boot(container);
}
// called by ASP.NET (auto event wireup) once per app domain
@@ -138,6 +143,8 @@ namespace Umbraco.Core
_runtime = null;
}
+ Current.Reset(); // dispose the container and everything
+
if (SystemUtilities.GetCurrentTrustLevel() != AspNetHostingPermissionLevel.Unrestricted) return;
// try to log the detailed shutdown message (typical asp.net hack: http://weblogs.asp.net/scottgu/433194)
diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
index b6af4eee19..20ebf27ec6 100644
--- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
+++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
@@ -14,9 +14,9 @@ using Umbraco.Web.Security;
namespace Umbraco.Tests.Cache.PublishedCache
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture]
- public class PublishContentCacheTests : BaseWebTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
+ public class PublishContentCacheTests : BaseWebTest
{
private FakeHttpContextFactory _httpContextFactory;
private UmbracoContext _umbracoContext;
diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs
index e42a72d4e3..8015757fc6 100644
--- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs
+++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs
@@ -16,8 +16,8 @@ using Current = Umbraco.Web.Current;
namespace Umbraco.Tests.Cache.PublishedCache
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class PublishMediaCacheTests : BaseWebTest
{
protected override void MoreSetUp()
diff --git a/src/Umbraco.Tests/Components/ComponentTests.cs b/src/Umbraco.Tests/Components/ComponentTests.cs
index 85df5b97c6..95cfe89342 100644
--- a/src/Umbraco.Tests/Components/ComponentTests.cs
+++ b/src/Umbraco.Tests/Components/ComponentTests.cs
@@ -5,29 +5,28 @@ using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Components;
-using Umbraco.Core.DI;
using Umbraco.Core.Logging;
-using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Components
{
[TestFixture]
- public class ComponentTests : BaseTestBase
+ public class ComponentTests
{
private static readonly List Composed = new List();
private static readonly List Initialized = new List();
+ private static IServiceContainer MockContainer(Action> setup = null)
+ {
+ var mock = new Mock();
+ mock.Setup(x => x.GetInstance()).Returns(new ProfilingLogger(Mock.Of(), Mock.Of()));
+ setup?.Invoke(mock);
+ return mock.Object;
+ }
+
[Test]
public void Boot()
{
- var container = new ServiceContainer();
- container.ConfigureUmbracoCore();
-
- var logger = Mock.Of();
- var profiler = new LogProfiler(logger);
- container.RegisterInstance(logger);
- container.RegisterInstance(profiler);
- container.RegisterInstance(new ProfilingLogger(logger, profiler));
+ var container = MockContainer();
var thing = new BootLoader(container);
Composed.Clear();
@@ -42,14 +41,7 @@ namespace Umbraco.Tests.Components
[Test]
public void BrokenDependency()
{
- var container = new ServiceContainer();
- container.ConfigureUmbracoCore();
-
- var logger = Mock.Of();
- var profiler = new LogProfiler(logger);
- container.RegisterInstance(logger);
- container.RegisterInstance(profiler);
- container.RegisterInstance(new ProfilingLogger(logger, profiler));
+ var container = MockContainer();
var thing = new BootLoader(container);
Composed.Clear();
@@ -67,16 +59,10 @@ namespace Umbraco.Tests.Components
[Test]
public void Initialize()
{
- var container = new ServiceContainer();
- container.ConfigureUmbracoCore();
-
- container.Register();
-
- var logger = Mock.Of();
- var profiler = new LogProfiler(logger);
- container.RegisterInstance(logger);
- container.RegisterInstance(profiler);
- container.RegisterInstance(new ProfilingLogger(logger, profiler));
+ var container = MockContainer(m =>
+ {
+ m.Setup(x => x.TryGetInstance(It.Is(t => t == typeof (ISomeResource)))).Returns(() => new SomeResource());
+ });
var thing = new BootLoader(container);
Composed.Clear();
@@ -91,14 +77,7 @@ namespace Umbraco.Tests.Components
[Test]
public void Requires1()
{
- var container = new ServiceContainer();
- container.ConfigureUmbracoCore();
-
- var logger = Mock.Of();
- var profiler = new LogProfiler(logger);
- container.RegisterInstance(logger);
- container.RegisterInstance(profiler);
- container.RegisterInstance(new ProfilingLogger(logger, profiler));
+ var container = MockContainer();
var thing = new BootLoader(container);
Composed.Clear();
@@ -111,14 +90,7 @@ namespace Umbraco.Tests.Components
[Test]
public void Requires2()
{
- var container = new ServiceContainer();
- container.ConfigureUmbracoCore();
-
- var logger = Mock.Of();
- var profiler = new LogProfiler(logger);
- container.RegisterInstance(logger);
- container.RegisterInstance(profiler);
- container.RegisterInstance(new ProfilingLogger(logger, profiler));
+ var container = MockContainer();
var thing = new BootLoader(container);
Composed.Clear();
@@ -132,14 +104,7 @@ namespace Umbraco.Tests.Components
[Test]
public void WeakDependencies()
{
- var container = new ServiceContainer();
- container.ConfigureUmbracoCore();
-
- var logger = Mock.Of();
- var profiler = new LogProfiler(logger);
- container.RegisterInstance(logger);
- container.RegisterInstance(profiler);
- container.RegisterInstance(new ProfilingLogger(logger, profiler));
+ var container = MockContainer();
var thing = new BootLoader(container);
Composed.Clear();
@@ -165,14 +130,7 @@ namespace Umbraco.Tests.Components
[Test]
public void DisableMissing()
{
- var container = new ServiceContainer();
- container.ConfigureUmbracoCore();
-
- var logger = Mock.Of();
- var profiler = new LogProfiler(logger);
- container.RegisterInstance(logger);
- container.RegisterInstance(profiler);
- container.RegisterInstance(new ProfilingLogger(logger, profiler));
+ var container = MockContainer();
var thing = new BootLoader(container);
Composed.Clear();
diff --git a/src/Umbraco.Tests/Integration/ContentEventsTests.cs b/src/Umbraco.Tests/Integration/ContentEventsTests.cs
index 992304dd86..4aee642ca9 100644
--- a/src/Umbraco.Tests/Integration/ContentEventsTests.cs
+++ b/src/Umbraco.Tests/Integration/ContentEventsTests.cs
@@ -19,9 +19,9 @@ using Umbraco.Web.Cache;
namespace Umbraco.Tests.Integration
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- public class ContentEventsTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
+ public class ContentEventsTests : TestWithSomeContentBase
{
#region Setup
diff --git a/src/Umbraco.Tests/Integration/GetCultureTests.cs b/src/Umbraco.Tests/Integration/GetCultureTests.cs
index 8d85193347..9b16619364 100644
--- a/src/Umbraco.Tests/Integration/GetCultureTests.cs
+++ b/src/Umbraco.Tests/Integration/GetCultureTests.cs
@@ -15,9 +15,9 @@ using Language = umbraco.cms.businesslogic.language.Language;
namespace Umbraco.Tests.Integration
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- public class GetCultureTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
+ public class GetCultureTests : TestWithSomeContentBase
{
protected override void MoreSetUp()
{
diff --git a/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs b/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs
index 01bf02c35d..f256c5ef98 100644
--- a/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs
+++ b/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs
@@ -1,18 +1,12 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Data;
using System.Linq;
-using LightInject;
using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Logging;
-using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Migrations;
-using Umbraco.Core.Persistence.SqlSyntax;
-using Umbraco.Core.Profiling;
-using Umbraco.Core.Services;
using Umbraco.Tests.Migrations.Stubs;
using Umbraco.Tests.TestHelpers;
@@ -21,7 +15,6 @@ namespace Umbraco.Tests.Migrations
[TestFixture]
public class FindingMigrationsTest : TestWithDatabaseBase
{
-
[Test]
public void Can_Find_Migrations_With_Target_Version_Six()
{
@@ -54,7 +47,6 @@ namespace Umbraco.Tests.Migrations
}
Assert.That(list.Count, Is.EqualTo(3));
-
foreach (var migration1 in list)
{
diff --git a/src/Umbraco.Tests/Migrations/MigrationIssuesTests.cs b/src/Umbraco.Tests/Migrations/MigrationIssuesTests.cs
index 2a43a7511d..cebbe90cb1 100644
--- a/src/Umbraco.Tests/Migrations/MigrationIssuesTests.cs
+++ b/src/Umbraco.Tests/Migrations/MigrationIssuesTests.cs
@@ -17,7 +17,7 @@ using GlobalSettings = Umbraco.Core.Configuration.GlobalSettings;
namespace Umbraco.Tests.Migrations
{
[TestFixture]
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class MigrationIssuesTests : TestWithDatabaseBase
{
[Test]
diff --git a/src/Umbraco.Tests/MockTests.cs b/src/Umbraco.Tests/MockTests.cs
index eb0aa67b5b..3f3d61b741 100644
--- a/src/Umbraco.Tests/MockTests.cs
+++ b/src/Umbraco.Tests/MockTests.cs
@@ -23,9 +23,8 @@ using Current = Umbraco.Web.Current;
namespace Umbraco.Tests
{
[TestFixture]
- public class MockTests : BaseTestBase
+ public class MockTests : UmbracoTestBase
{
- [SetUp]
public override void SetUp()
{
base.SetUp();
@@ -66,14 +65,11 @@ namespace Umbraco.Tests
{
var umbracoContext = TestObjects.GetUmbracoContextMock();
- var container = new ServiceContainer();
- container.ConfigureUmbracoCore();
-
// unless we can inject them in MembershipHelper, we need need this
- container.Register(_ => Mock.Of());
- container.Register(_ => Mock.Of());
- container.Register(_ => CacheHelper.CreateDisabledCacheHelper());
- container.Register();
+ Container.Register(_ => Mock.Of());
+ Container.Register(_ => Mock.Of());
+ Container.Register(_ => CacheHelper.CreateDisabledCacheHelper());
+ Container.Register();
// ReSharper disable once UnusedVariable
var helper = new UmbracoHelper(umbracoContext,
diff --git a/src/Umbraco.Tests/Models/ContentTests.cs b/src/Umbraco.Tests/Models/ContentTests.cs
index a4ff55546e..8279fd7cb9 100644
--- a/src/Umbraco.Tests/Models/ContentTests.cs
+++ b/src/Umbraco.Tests/Models/ContentTests.cs
@@ -26,27 +26,22 @@ namespace Umbraco.Tests.Models
[TestFixture]
public class ContentTests : TestWithSettingsBase
{
- private ServiceContainer _container;
-
public override void SetUp()
{
base.SetUp();
var config = SettingsForTests.GetDefault();
SettingsForTests.ConfigureSettings(config);
-
- _container = new ServiceContainer();
- _container.ConfigureUmbracoCore();
- _container.Register(_ => Mock.Of());
- _container.Register();
- _container.Register(_ => Mock.Of());
- _container.Register(_ => Mock.Of());
}
- public override void TearDown()
+ protected override void Compose()
{
- base.TearDown();
- _container.Dispose();
+ base.Compose();
+
+ Container.Register(_ => Mock.Of());
+ Container.Register();
+ Container.Register(_ => Mock.Of());
+ Container.Register(_ => Mock.Of());
}
[Test]
diff --git a/src/Umbraco.Tests/Models/ContentXmlTest.cs b/src/Umbraco.Tests/Models/ContentXmlTest.cs
index e4c4361952..616f8a3365 100644
--- a/src/Umbraco.Tests/Models/ContentXmlTest.cs
+++ b/src/Umbraco.Tests/Models/ContentXmlTest.cs
@@ -9,8 +9,8 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Models
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
public class ContentXmlTest : TestWithDatabaseBase
{
[Test]
diff --git a/src/Umbraco.Tests/Models/Mapping/AutoMapperTests.cs b/src/Umbraco.Tests/Models/Mapping/AutoMapperTests.cs
index 226ed0b05e..1704a99229 100644
--- a/src/Umbraco.Tests/Models/Mapping/AutoMapperTests.cs
+++ b/src/Umbraco.Tests/Models/Mapping/AutoMapperTests.cs
@@ -14,8 +14,8 @@ using Umbraco.Core.DI;
namespace Umbraco.Tests.Models.Mapping
{
- [RequiresAutoMapperMappings]
[TestFixture]
+ [UmbracoTest(AutoMapper = true)]
public class AutoMapperTests : TestWithApplicationBase
{
protected override void Compose()
diff --git a/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs b/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs
index c65ffc843d..73192ff1ae 100644
--- a/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs
+++ b/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs
@@ -28,6 +28,7 @@ namespace Umbraco.Tests.Models.Mapping
private readonly Mock _dataTypeService = new Mock();
private readonly Mock _entityService = new Mock();
private readonly Mock _fileService = new Mock();
+ private Mock _editorsMock;
public override void SetUp()
{
@@ -54,15 +55,11 @@ namespace Umbraco.Tests.Models.Mapping
// nullCacheHelper,
// new ProfilingLogger(logger, Mock.Of()));
- // create a fake property editor collection to return fake property editors
- var editors = new PropertyEditor[] { new TextboxPropertyEditor(Mock.Of()), };
- var editorsMock = new Mock(new object[] { editors });
- editorsMock.Setup(x => x[It.IsAny()]).Returns(editors[0]);
-
+ // fixme - are we initializing mappers that... have already been?
Mapper.Initialize(configuration =>
{
//initialize our content type mapper
- var mapper = new ContentTypeModelMapper(editorsMock.Object, _dataTypeService.Object, _fileService.Object, _contentTypeService.Object, Mock.Of());
+ var mapper = new ContentTypeModelMapper(_editorsMock.Object, _dataTypeService.Object, _fileService.Object, _contentTypeService.Object, Mock.Of());
mapper.ConfigureMappings(configuration);
var entityMapper = new EntityModelMapper();
entityMapper.ConfigureMappings(configuration);
@@ -73,6 +70,12 @@ namespace Umbraco.Tests.Models.Mapping
{
base.Compose();
+ // create and register a fake property editor collection to return fake property editors
+ var editors = new PropertyEditor[] { new TextboxPropertyEditor(Mock.Of()), };
+ _editorsMock = new Mock(new object[] { editors });
+ _editorsMock.Setup(x => x[It.IsAny()]).Returns(editors[0]);
+ Container.RegisterSingleton(f => _editorsMock.Object);
+
Container.RegisterSingleton(_ => _contentTypeService.Object);
Container.RegisterSingleton(_ => _contentService.Object);
Container.RegisterSingleton(_ => _dataTypeService.Object);
diff --git a/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs b/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs
index 0849c195d9..1707997fdd 100644
--- a/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs
+++ b/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs
@@ -17,9 +17,8 @@ using Current = Umbraco.Web.Current;
namespace Umbraco.Tests.Models.Mapping
{
- [RequiresAutoMapperMappings]
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture]
+ [UmbracoTest(AutoMapper = true, Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
public class ContentWebModelMappingTests : TestWithDatabaseBase
{
protected override void MoreSetUp()
diff --git a/src/Umbraco.Tests/Models/MediaXmlTest.cs b/src/Umbraco.Tests/Models/MediaXmlTest.cs
index 8b4f6d6b3f..86934ee7a2 100644
--- a/src/Umbraco.Tests/Models/MediaXmlTest.cs
+++ b/src/Umbraco.Tests/Models/MediaXmlTest.cs
@@ -15,8 +15,8 @@ using Umbraco.Web.PropertyEditors;
namespace Umbraco.Tests.Models
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
public class MediaXmlTest : TestWithDatabaseBase
{
[Test]
diff --git a/src/Umbraco.Tests/Persistence/NPocoExtensionsTest.cs b/src/Umbraco.Tests/Persistence/NPocoExtensionsTest.cs
index 5ef18efea0..e4c024e754 100644
--- a/src/Umbraco.Tests/Persistence/NPocoExtensionsTest.cs
+++ b/src/Umbraco.Tests/Persistence/NPocoExtensionsTest.cs
@@ -14,8 +14,8 @@ namespace Umbraco.Tests.Persistence
{
// fixme.npoco - is this still appropriate?
//
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class NPocoExtensionsTest : TestWithDatabaseBase
{
[Test]
diff --git a/src/Umbraco.Tests/Persistence/PetaPocoCachesTest.cs b/src/Umbraco.Tests/Persistence/PetaPocoCachesTest.cs
index bbec78805c..8a7fd50440 100644
--- a/src/Umbraco.Tests/Persistence/PetaPocoCachesTest.cs
+++ b/src/Umbraco.Tests/Persistence/PetaPocoCachesTest.cs
@@ -15,9 +15,9 @@ namespace Umbraco.Tests.Persistence
{
// fixme.npoco - what shall we do with those tests?
//
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, Ignore]
- public class PetaPocoCachesTest : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
+ public class PetaPocoCachesTest : TestWithSomeContentBase
{
#if DEBUG
diff --git a/src/Umbraco.Tests/Persistence/Querying/ContentTypeSqlMappingTests.cs b/src/Umbraco.Tests/Persistence/Querying/ContentTypeSqlMappingTests.cs
index bc7bbd9ff6..e3ffa643f6 100644
--- a/src/Umbraco.Tests/Persistence/Querying/ContentTypeSqlMappingTests.cs
+++ b/src/Umbraco.Tests/Persistence/Querying/ContentTypeSqlMappingTests.cs
@@ -15,8 +15,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence.Querying
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class ContentTypeSqlMappingTests : TestWithDatabaseBase
{
[Test]
diff --git a/src/Umbraco.Tests/Persistence/Repositories/AuditRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/AuditRepositoryTest.cs
index 7c4481578e..2d80f8f569 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/AuditRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/AuditRepositoryTest.cs
@@ -8,8 +8,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class AuditRepositoryTest : TestWithDatabaseBase
{
[Test]
diff --git a/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs
index 9613af3c7d..05fb7f1f43 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs
@@ -25,8 +25,8 @@ using Umbraco.Core.Persistence.SqlSyntax;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class ContentRepositoryTest : TestWithDatabaseBase
{
public override void SetUp()
diff --git a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs
index 94461196cb..43547f13db 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs
@@ -23,9 +23,8 @@ using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.Tests.Persistence.Repositories
{
- [RequiresAutoMapperMappings]
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(AutoMapper = true, Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class ContentTypeRepositoryTest : TestWithDatabaseBase
{
public override void SetUp()
diff --git a/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs
index 3add643bdb..2230762d25 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs
@@ -1,49 +1,59 @@
using System;
-using System.Data;
using System.Linq;
-using System.Reflection;
using System.Text.RegularExpressions;
-using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
-using Umbraco.Core.Configuration.UmbracoSettings;
-using Umbraco.Core.DI;
-using Umbraco.Core.IO;
-using Umbraco.Core.Logging;
using Umbraco.Core.Models;
-using Umbraco.Core.Models.Membership;
using Umbraco.Core.Models.Rdbms;
-using Umbraco.Core.Persistence;
-using Umbraco.Core.Persistence.Mappers;
-using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.UnitOfWork;
using Umbraco.Tests.TestHelpers;
-using Umbraco.Tests.TestHelpers.Entities;
+using Umbraco.Core.DI;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class DataTypeDefinitionRepositoryTest : TestWithDatabaseBase
{
- protected override CacheHelper CreateCacheHelper()
+ //protected override CacheHelper CreateCacheHelper()
+ //{
+ // // hackish, but it works
+ // var testName = TestContext.CurrentContext.Test.Name;
+ // if (testName == "Can_Get_Pre_Value_As_String_With_Cache"
+ // || testName == "Can_Get_Pre_Value_Collection_With_Cache")
+ // {
+ // return new CacheHelper(
+ // new ObjectCacheRuntimeCacheProvider(),
+ // new StaticCacheProvider(),
+ // new StaticCacheProvider(),
+ // new IsolatedRuntimeCache(type => new ObjectCacheRuntimeCacheProvider())); // default would be NullCacheProvider
+ // }
+
+ // return base.CreateCacheHelper();
+ //}
+
+ protected override void ComposeCacheHelper()
{
// hackish, but it works
var testName = TestContext.CurrentContext.Test.Name;
- if (testName == "Can_Get_Pre_Value_As_String_With_Cache"
- || testName == "Can_Get_Pre_Value_Collection_With_Cache")
+ if (testName == "Can_Get_Pre_Value_As_String_With_Cache" || testName == "Can_Get_Pre_Value_Collection_With_Cache")
{
- return new CacheHelper(
+ var cacheHelper = new CacheHelper(
new ObjectCacheRuntimeCacheProvider(),
new StaticCacheProvider(),
new StaticCacheProvider(),
new IsolatedRuntimeCache(type => new ObjectCacheRuntimeCacheProvider())); // default would be NullCacheProvider
- }
- return base.CreateCacheHelper();
+ Container.RegisterSingleton(f => cacheHelper);
+ Container.RegisterSingleton(f => f.GetInstance().RuntimeCache);
+ }
+ else
+ {
+ base.ComposeCacheHelper();
+ }
}
private IDataTypeDefinitionRepository CreateRepository(IDatabaseUnitOfWork unitOfWork)
diff --git a/src/Umbraco.Tests/Persistence/Repositories/DictionaryRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/DictionaryRepositoryTest.cs
index 0a5cfdf49d..ead4dc788a 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/DictionaryRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/DictionaryRepositoryTest.cs
@@ -15,8 +15,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class DictionaryRepositoryTest : TestWithDatabaseBase
{
public override void SetUp()
diff --git a/src/Umbraco.Tests/Persistence/Repositories/DomainRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/DomainRepositoryTest.cs
index 8291bcfa00..f77d4780b6 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/DomainRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/DomainRepositoryTest.cs
@@ -13,8 +13,8 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class DomainRepositoryTest : TestWithDatabaseBase
{
private DomainRepository CreateRepository(IDatabaseUnitOfWork unitOfWork, out ContentTypeRepository contentTypeRepository, out ContentRepository contentRepository, out LanguageRepository languageRepository)
diff --git a/src/Umbraco.Tests/Persistence/Repositories/LanguageRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/LanguageRepositoryTest.cs
index 22c01e458f..5cbcd093a8 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/LanguageRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/LanguageRepositoryTest.cs
@@ -15,8 +15,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class LanguageRepositoryTest : TestWithDatabaseBase
{
public override void SetUp()
diff --git a/src/Umbraco.Tests/Persistence/Repositories/MacroRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MacroRepositoryTest.cs
index f4cebb5af7..385e682029 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/MacroRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/MacroRepositoryTest.cs
@@ -15,8 +15,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class MacroRepositoryTest : TestWithDatabaseBase
{
public override void SetUp()
diff --git a/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs
index 5810842a14..5fabea8f9c 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs
@@ -17,8 +17,8 @@ using Umbraco.Core.Persistence.DatabaseModelDefinitions;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class MediaRepositoryTest : TestWithDatabaseBase
{
public override void SetUp()
diff --git a/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs
index abd0d61c94..153148bef1 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs
@@ -16,8 +16,8 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class MediaTypeRepositoryTest : TestWithDatabaseBase
{
private MediaTypeRepository CreateRepository(IDatabaseUnitOfWork unitOfWork)
diff --git a/src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs
index fa74baa3aa..7e1abe4252 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs
@@ -20,8 +20,8 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class MemberRepositoryTest : TestWithDatabaseBase
{
private MemberRepository CreateRepository(IDatabaseUnitOfWork unitOfWork, out MemberTypeRepository memberTypeRepository, out MemberGroupRepository memberGroupRepository)
diff --git a/src/Umbraco.Tests/Persistence/Repositories/MemberTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MemberTypeRepositoryTest.cs
index c5acb91374..b3739c4e44 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/MemberTypeRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/MemberTypeRepositoryTest.cs
@@ -15,8 +15,8 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class MemberTypeRepositoryTest : TestWithDatabaseBase
{
private MemberTypeRepository CreateRepository(IDatabaseUnitOfWork unitOfWork)
diff --git a/src/Umbraco.Tests/Persistence/Repositories/NotificationsRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/NotificationsRepositoryTest.cs
index ec86ad80ba..ed616195b7 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/NotificationsRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/NotificationsRepositoryTest.cs
@@ -13,8 +13,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class NotificationsRepositoryTest : TestWithDatabaseBase
{
[Test]
diff --git a/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs b/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs
index 2b80270a1b..fcc1e6007d 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs
@@ -9,7 +9,9 @@ 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;
namespace Umbraco.Tests.Persistence.Repositories
{
@@ -25,6 +27,13 @@ namespace Umbraco.Tests.Persistence.Repositories
_fileSystem = new PhysicalFileSystem(SystemDirectories.MvcViews + "/Partials/");
}
+ protected override void Compose()
+ {
+ base.Compose();
+
+ Container.RegisterSingleton(f => new PropertyEditorCollection(Enumerable.Empty()));
+ }
+
[Test]
public void PathTests()
{
diff --git a/src/Umbraco.Tests/Persistence/Repositories/PublicAccessRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/PublicAccessRepositoryTest.cs
index 4a4e8c02cb..bdcb98fcd6 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/PublicAccessRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/PublicAccessRepositoryTest.cs
@@ -16,8 +16,8 @@ using Content = Umbraco.Core.Models.Content;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class PublicAccessRepositoryTest : TestWithDatabaseBase
{
[Test]
diff --git a/src/Umbraco.Tests/Persistence/Repositories/RedirectUrlRepositoryTests.cs b/src/Umbraco.Tests/Persistence/Repositories/RedirectUrlRepositoryTests.cs
index 0a2a4a05f0..efbfd89fa4 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/RedirectUrlRepositoryTests.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/RedirectUrlRepositoryTests.cs
@@ -10,8 +10,8 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class RedirectUrlRepositoryTests : TestWithDatabaseBase
{
public override void SetUp()
diff --git a/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs
index 3dcdc843e6..c1190ca704 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs
@@ -17,8 +17,8 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class RelationRepositoryTest : TestWithDatabaseBase
{
public override void SetUp()
diff --git a/src/Umbraco.Tests/Persistence/Repositories/RelationTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/RelationTypeRepositoryTest.cs
index 6e5464a4c1..9f7d26bdeb 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/RelationTypeRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/RelationTypeRepositoryTest.cs
@@ -16,8 +16,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class RelationTypeRepositoryTest : TestWithDatabaseBase
{
public override void SetUp()
diff --git a/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs
index 5b2d54592a..d90075bbf5 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs
@@ -4,11 +4,13 @@ using System.Text;
using Moq;
using NUnit.Framework;
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;
namespace Umbraco.Tests.Persistence.Repositories
@@ -29,6 +31,13 @@ namespace Umbraco.Tests.Persistence.Repositories
}
}
+ protected override void Compose()
+ {
+ base.Compose();
+
+ Container.RegisterSingleton(f => new PropertyEditorCollection(Enumerable.Empty()));
+ }
+
[Test]
public void Can_Instantiate_Repository()
{
diff --git a/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs
index 0f51c9014e..9a829593a4 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs
@@ -15,8 +15,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class ServerRegistrationRepositoryTest : TestWithDatabaseBase
{
private CacheHelper _cacheHelper;
diff --git a/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs
index 23ce88bffb..cf2d36f6e1 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs
@@ -14,8 +14,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
public class StylesheetRepositoryTest : TestWithDatabaseBase
{
private IFileSystem _fileSystem;
diff --git a/src/Umbraco.Tests/Persistence/Repositories/TagRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/TagRepositoryTest.cs
index ba88528333..74c0833bd5 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/TagRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/TagRepositoryTest.cs
@@ -17,8 +17,8 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class TagRepositoryTest : TestWithDatabaseBase
{
private TagRepository CreateRepository(IDatabaseUnitOfWork unitOfWork)
diff --git a/src/Umbraco.Tests/Persistence/Repositories/TaskRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/TaskRepositoryTest.cs
index 336064f66a..d81f57ad7a 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/TaskRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/TaskRepositoryTest.cs
@@ -9,8 +9,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class TaskRepositoryTest : TestWithDatabaseBase
{
[Test]
diff --git a/src/Umbraco.Tests/Persistence/Repositories/TaskTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/TaskTypeRepositoryTest.cs
index fc079c5021..7c3c6c40ba 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/TaskTypeRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/TaskTypeRepositoryTest.cs
@@ -8,8 +8,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class TaskTypeRepositoryTest : TestWithDatabaseBase
{
[Test]
diff --git a/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs
index b26b32ecdf..1202e9d893 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs
@@ -21,8 +21,8 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class TemplateRepositoryTest : TestWithDatabaseBase
{
private IFileSystem _masterPageFileSystem;
diff --git a/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs
index 67ced24ade..4a93ed793c 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs
@@ -17,8 +17,8 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class UserRepositoryTest : TestWithDatabaseBase
{
private UserRepository CreateRepository(IDatabaseUnitOfWork unitOfWork, out UserTypeRepository userTypeRepository)
diff --git a/src/Umbraco.Tests/Persistence/Repositories/UserTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/UserTypeRepositoryTest.cs
index 571acbdb74..940d6b7ae7 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/UserTypeRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/UserTypeRepositoryTest.cs
@@ -15,8 +15,8 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Persistence.Repositories
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class UserTypeRepositoryTest : TestWithDatabaseBase
{
private UserTypeRepository CreateRepository(IDatabaseUnitOfWork unitOfWork)
diff --git a/src/Umbraco.Tests/Persistence/SchemaValidationTest.cs b/src/Umbraco.Tests/Persistence/SchemaValidationTest.cs
index 5f005da7ab..8ea89aa8d4 100644
--- a/src/Umbraco.Tests/Persistence/SchemaValidationTest.cs
+++ b/src/Umbraco.Tests/Persistence/SchemaValidationTest.cs
@@ -8,8 +8,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
public class SchemaValidationTest : TestWithDatabaseBase
{
[Test]
diff --git a/src/Umbraco.Tests/Persistence/SqlCeTableByTableTest.cs b/src/Umbraco.Tests/Persistence/SqlCeTableByTableTest.cs
index 1a71b256a0..db4b40cca3 100644
--- a/src/Umbraco.Tests/Persistence/SqlCeTableByTableTest.cs
+++ b/src/Umbraco.Tests/Persistence/SqlCeTableByTableTest.cs
@@ -5,8 +5,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class SqlCeTableByTableTest : TestWithDatabaseBase
{
private DatabaseSchemaHelper _schemaHelper;
diff --git a/src/Umbraco.Tests/Persistence/UnitOfWorkTests.cs b/src/Umbraco.Tests/Persistence/UnitOfWorkTests.cs
index bc2eda432c..86d743c625 100644
--- a/src/Umbraco.Tests/Persistence/UnitOfWorkTests.cs
+++ b/src/Umbraco.Tests/Persistence/UnitOfWorkTests.cs
@@ -10,8 +10,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class UnitOfWorkTests : TestWithDatabaseBase
{
[Test]
diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentExtensionTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentExtensionTests.cs
index 982dc8f04f..adcc3b540e 100644
--- a/src/Umbraco.Tests/PublishedContent/PublishedContentExtensionTests.cs
+++ b/src/Umbraco.Tests/PublishedContent/PublishedContentExtensionTests.cs
@@ -9,8 +9,8 @@ using Umbraco.Web;
namespace Umbraco.Tests.PublishedContent
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
public class PublishedContentExtensionTests : PublishedContentTestBase
{
private UmbracoContext ctx;
diff --git a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs
index ac9cb7081f..304c27588f 100644
--- a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs
+++ b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs
@@ -25,8 +25,8 @@ namespace Umbraco.Tests.PublishedContent
///
/// Tests the typed extension methods on IPublishedContent using the DefaultPublishedMediaStore
///
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class PublishedMediaTests : PublishedContentTestBase
{
///
diff --git a/src/Umbraco.Tests/Publishing/PublishingStrategyTests.cs b/src/Umbraco.Tests/Publishing/PublishingStrategyTests.cs
index 40714fbae2..eb636d6d35 100644
--- a/src/Umbraco.Tests/Publishing/PublishingStrategyTests.cs
+++ b/src/Umbraco.Tests/Publishing/PublishingStrategyTests.cs
@@ -10,8 +10,8 @@ using Umbraco.Core.Services;
namespace Umbraco.Tests.Publishing
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class PublishingStrategyTests : TestWithDatabaseBase
{
public override void SetUp()
diff --git a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlAndTemplateTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlAndTemplateTests.cs
index 75ecede0ef..00cbd89bb3 100644
--- a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlAndTemplateTests.cs
+++ b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlAndTemplateTests.cs
@@ -6,9 +6,9 @@ using Current = Umbraco.Web.Current;
namespace Umbraco.Tests.Routing
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture]
- public class ContentFinderByNiceUrlAndTemplateTests : BaseWebTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
+ public class ContentFinderByNiceUrlAndTemplateTests : BaseWebTest
{
Template CreateTemplate(string alias)
{
diff --git a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlTests.cs
index f2eb62b3da..a27f3050f9 100644
--- a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlTests.cs
+++ b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlTests.cs
@@ -4,9 +4,9 @@ using Umbraco.Web.Routing;
namespace Umbraco.Tests.Routing
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
- public class ContentFinderByNiceUrlTests : BaseWebTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
+ public class ContentFinderByNiceUrlTests : BaseWebTest
{
[TestCase("/", 1046)]
[TestCase("/default.aspx", 1046)] //this one is actually rather important since this is the path that comes through when we are running in pre-IIS 7 for the root document '/' !
diff --git a/src/Umbraco.Tests/Routing/NiceUrlProviderTests.cs b/src/Umbraco.Tests/Routing/NiceUrlProviderTests.cs
index 02ff579104..187e2082fb 100644
--- a/src/Umbraco.Tests/Routing/NiceUrlProviderTests.cs
+++ b/src/Umbraco.Tests/Routing/NiceUrlProviderTests.cs
@@ -10,9 +10,9 @@ using Umbraco.Web.Routing;
namespace Umbraco.Tests.Routing
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture]
- public class NiceUrlProviderTests : BaseWebTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
+ public class NiceUrlProviderTests : BaseWebTest
{
protected override void MoreSetUp()
{
diff --git a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
index afd6a01629..fa87473714 100644
--- a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
+++ b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
@@ -21,9 +21,9 @@ using Current = Umbraco.Web.Current;
namespace Umbraco.Tests.Routing
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture]
- public class RenderRouteHandlerTests : BaseWebTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
+ public class RenderRouteHandlerTests : BaseWebTest
{
public override void SetUp()
{
diff --git a/src/Umbraco.Tests/Routing/RoutesCacheTests.cs b/src/Umbraco.Tests/Routing/RoutesCacheTests.cs
index 14be184706..587ce2d5bb 100644
--- a/src/Umbraco.Tests/Routing/RoutesCacheTests.cs
+++ b/src/Umbraco.Tests/Routing/RoutesCacheTests.cs
@@ -9,8 +9,8 @@ using Umbraco.Web.PublishedCache.XmlPublishedCache;
namespace Umbraco.Tests.Routing
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
public class RoutesCacheTests : BaseWebTest
{
[Test]
diff --git a/src/Umbraco.Tests/Routing/UrlRoutingTestBase.cs b/src/Umbraco.Tests/Routing/UrlRoutingTestBase.cs
index f14e4d4a5d..9c9f0967be 100644
--- a/src/Umbraco.Tests/Routing/UrlRoutingTestBase.cs
+++ b/src/Umbraco.Tests/Routing/UrlRoutingTestBase.cs
@@ -9,8 +9,8 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Routing
{
- [DatabaseTestBehavior(DatabaseBehavior.NoDatabasePerFixture)]
[TestFixture]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
public abstract class UrlRoutingTestBase : BaseWebTest
{
///
diff --git a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs
index e63685a617..6b1c66c53a 100644
--- a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs
+++ b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs
@@ -17,19 +17,16 @@ using UmbracoExamine;
namespace Umbraco.Tests.Runtimes
{
[TestFixture]
- public class CoreRuntimeTests : TestWithSettingsBase
+ public class CoreRuntimeTests
{
- public override void SetUp()
+ [SetUp]
+ public void SetUp()
{
- base.SetUp();
-
TestComponent.Reset();
}
- public override void TearDown()
+ public void TearDown()
{
- base.TearDown();
-
TestComponent.Reset();
}
@@ -71,6 +68,10 @@ namespace Umbraco.Tests.Runtimes
//return Mock.Of();
return new DebugDiagnosticsLogger();
}
+
+ // don't register anything against AppDomain
+ protected override void ConfigureUnhandledException(ILogger logger)
+ { }
}
// test runtime
diff --git a/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs b/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs
index 0513cc82b4..70caaa40b4 100644
--- a/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs
+++ b/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs
@@ -17,8 +17,8 @@ using Current = Umbraco.Web.Current;
namespace Umbraco.Tests.Services
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, NUnit.Framework.Ignore]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class ContentServicePerformanceTest : TestWithDatabaseBase
{
public override void SetUp()
diff --git a/src/Umbraco.Tests/Services/ContentServiceTests.cs b/src/Umbraco.Tests/Services/ContentServiceTests.cs
index 40622292ef..904d00f3cc 100644
--- a/src/Umbraco.Tests/Services/ContentServiceTests.cs
+++ b/src/Umbraco.Tests/Services/ContentServiceTests.cs
@@ -27,10 +27,9 @@ namespace Umbraco.Tests.Services
/// This is more of an integration test as it involves multiple layers
/// as well as configuration.
///
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- [TestSetup.FacadeService(EnableRepositoryEvents = true)]
- public class ContentServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, FacadeServiceRepositoryEvents = true)]
+ public class ContentServiceTests : TestWithSomeContentBase
{
//TODO Add test to verify there is only ONE newest document/content in cmsDocument table after updating.
//TODO Add test to delete specific version (with and without deleting prior versions) and versions by date.
diff --git a/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs b/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs
index bba2d54bd3..5051f5c2b8 100644
--- a/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs
+++ b/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs
@@ -13,11 +13,9 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Services
{
-
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- [TestSetup.FacadeService(EnableRepositoryEvents = true)]
- public class ContentTypeServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, FacadeServiceRepositoryEvents = true)]
+ public class ContentTypeServiceTests : TestWithSomeContentBase
{
[Test]
public void Deleting_PropertyType_Removes_The_Property_From_Content()
diff --git a/src/Umbraco.Tests/Services/DataTypeServiceTests.cs b/src/Umbraco.Tests/Services/DataTypeServiceTests.cs
index 85236bd1ae..92aa427c3b 100644
--- a/src/Umbraco.Tests/Services/DataTypeServiceTests.cs
+++ b/src/Umbraco.Tests/Services/DataTypeServiceTests.cs
@@ -12,9 +12,9 @@ namespace Umbraco.Tests.Services
///
/// Tests covering the DataTypeService
///
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- public class DataTypeServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
+ public class DataTypeServiceTests : TestWithSomeContentBase
{
[Test]
public void DataTypeService_Can_Persist_New_DataTypeDefinition()
diff --git a/src/Umbraco.Tests/Services/EntityServiceTests.cs b/src/Umbraco.Tests/Services/EntityServiceTests.cs
index db2416a67e..3b7d6206ae 100644
--- a/src/Umbraco.Tests/Services/EntityServiceTests.cs
+++ b/src/Umbraco.Tests/Services/EntityServiceTests.cs
@@ -11,9 +11,9 @@ namespace Umbraco.Tests.Services
///
/// Tests covering the EntityService
///
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture, RequiresSTA]
- public class EntityServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
+ public class EntityServiceTests : TestWithSomeContentBase
{
[Test]
public void EntityService_Can_Find_All_Content_By_UmbracoObjectTypes()
@@ -146,7 +146,7 @@ namespace Umbraco.Tests.Services
Assert.That(
entities.Any(
x =>
- x.AdditionalData.Any(y => y.Value is UmbracoEntity.EntityProperty
+ x.AdditionalData.Any(y => y.Value is UmbracoEntity.EntityProperty
&& ((UmbracoEntity.EntityProperty)y.Value).PropertyEditorAlias == Constants.PropertyEditors.UploadFieldAlias)), Is.True);
}
@@ -174,7 +174,7 @@ namespace Umbraco.Tests.Services
//Create and Save folder-Media -> 1050
var folderMediaType = ServiceContext.MediaTypeService.Get(1031);
- var folder = MockedMedia.CreateMediaFolder(folderMediaType, -1);
+ var folder = MockedMedia.CreateMediaFolder(folderMediaType, -1);
ServiceContext.MediaService.Save(folder, 0);
folderId = folder.Id;
@@ -192,9 +192,7 @@ namespace Umbraco.Tests.Services
ServiceContext.MediaService.Save(subfolder, 0);
var subfolder2 = MockedMedia.CreateMediaFolder(folderMediaType, subfolder.Id);
ServiceContext.MediaService.Save(subfolder2, 0);
-
}
-
}
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Tests/Services/FileServiceTests.cs b/src/Umbraco.Tests/Services/FileServiceTests.cs
index 85e3aa981c..d44c086e27 100644
--- a/src/Umbraco.Tests/Services/FileServiceTests.cs
+++ b/src/Umbraco.Tests/Services/FileServiceTests.cs
@@ -9,9 +9,9 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Services
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- public class FileServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
+ public class FileServiceTests : TestWithSomeContentBase
{
[Test]
public void Create_Template_Then_Assign_Child()
diff --git a/src/Umbraco.Tests/Services/Importing/PackageImportTests.cs b/src/Umbraco.Tests/Services/Importing/PackageImportTests.cs
index 5c503d9f24..acc65d8961 100644
--- a/src/Umbraco.Tests/Services/Importing/PackageImportTests.cs
+++ b/src/Umbraco.Tests/Services/Importing/PackageImportTests.cs
@@ -11,9 +11,9 @@ using Current = Umbraco.Web.Current;
namespace Umbraco.Tests.Services.Importing
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- public class PackageImportTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
+ public class PackageImportTests : TestWithSomeContentBase
{
[Test]
public void PackagingService_Can_Import_uBlogsy_ContentTypes_And_Verify_Structure()
diff --git a/src/Umbraco.Tests/Services/LocalizationServiceTests.cs b/src/Umbraco.Tests/Services/LocalizationServiceTests.cs
index 1b218212b5..4cb1909d81 100644
--- a/src/Umbraco.Tests/Services/LocalizationServiceTests.cs
+++ b/src/Umbraco.Tests/Services/LocalizationServiceTests.cs
@@ -14,9 +14,9 @@ namespace Umbraco.Tests.Services
/// This is more of an integration test as it involves multiple layers
/// as well as configuration.
///
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- public class LocalizationServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
+ public class LocalizationServiceTests : TestWithSomeContentBase
{
private Guid _parentItemGuidId;
private int _parentItemIntId;
diff --git a/src/Umbraco.Tests/Services/MacroServiceTests.cs b/src/Umbraco.Tests/Services/MacroServiceTests.cs
index 8fe9a0a850..884fdf0ecf 100644
--- a/src/Umbraco.Tests/Services/MacroServiceTests.cs
+++ b/src/Umbraco.Tests/Services/MacroServiceTests.cs
@@ -12,9 +12,9 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Services
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- public class MacroServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
+ public class MacroServiceTests : TestWithSomeContentBase
{
public override void CreateTestData()
{
diff --git a/src/Umbraco.Tests/Services/MediaServiceTests.cs b/src/Umbraco.Tests/Services/MediaServiceTests.cs
index 2855d22669..256f36adb4 100644
--- a/src/Umbraco.Tests/Services/MediaServiceTests.cs
+++ b/src/Umbraco.Tests/Services/MediaServiceTests.cs
@@ -14,10 +14,9 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Services
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- [TestSetup.FacadeService(EnableRepositoryEvents = true)]
- public class MediaServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, FacadeServiceRepositoryEvents = true)]
+ public class MediaServiceTests : TestWithSomeContentBase
{
[Test]
public void Can_Move_Media()
diff --git a/src/Umbraco.Tests/Services/MemberServiceTests.cs b/src/Umbraco.Tests/Services/MemberServiceTests.cs
index 5f6c2fe458..9837857b69 100644
--- a/src/Umbraco.Tests/Services/MemberServiceTests.cs
+++ b/src/Umbraco.Tests/Services/MemberServiceTests.cs
@@ -19,10 +19,9 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Services
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- [TestSetup.FacadeService(EnableRepositoryEvents = true)]
- public class MemberServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, FacadeServiceRepositoryEvents = true)]
+ public class MemberServiceTests : TestWithSomeContentBase
{
[Test]
public void Can_Create_Member()
diff --git a/src/Umbraco.Tests/Services/MemberTypeServiceTests.cs b/src/Umbraco.Tests/Services/MemberTypeServiceTests.cs
index 18b6c1f6f0..c80ad5e662 100644
--- a/src/Umbraco.Tests/Services/MemberTypeServiceTests.cs
+++ b/src/Umbraco.Tests/Services/MemberTypeServiceTests.cs
@@ -11,10 +11,9 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Services
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- [TestSetup.FacadeService(EnableRepositoryEvents = true)]
- public class MemberTypeServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, FacadeServiceRepositoryEvents = true)]
+ public class MemberTypeServiceTests : TestWithSomeContentBase
{
[Test]
public void Member_Cannot_Edit_Property()
diff --git a/src/Umbraco.Tests/Services/PackagingServiceTests.cs b/src/Umbraco.Tests/Services/PackagingServiceTests.cs
index 2096e0d876..bc412a45c8 100644
--- a/src/Umbraco.Tests/Services/PackagingServiceTests.cs
+++ b/src/Umbraco.Tests/Services/PackagingServiceTests.cs
@@ -13,9 +13,9 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Services
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
- public class PackagingServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
+ public class PackagingServiceTests : TestWithSomeContentBase
{
[Test]
public void PackagingService_Can_Export_Macro()
diff --git a/src/Umbraco.Tests/Services/PerformanceTests.cs b/src/Umbraco.Tests/Services/PerformanceTests.cs
index 92c8a625a7..d968358c14 100644
--- a/src/Umbraco.Tests/Services/PerformanceTests.cs
+++ b/src/Umbraco.Tests/Services/PerformanceTests.cs
@@ -28,8 +28,8 @@ namespace Umbraco.Tests.Services
/// This is more of an integration test as it involves multiple layers
/// as well as configuration.
///
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
[NUnit.Framework.Ignore("These should not be run by the server, only directly as they are only benchmark tests")]
public class PerformanceTests : TestWithDatabaseBase
{
diff --git a/src/Umbraco.Tests/Services/PublicAccessServiceTests.cs b/src/Umbraco.Tests/Services/PublicAccessServiceTests.cs
index 9ac2a99b67..39196fdcf2 100644
--- a/src/Umbraco.Tests/Services/PublicAccessServiceTests.cs
+++ b/src/Umbraco.Tests/Services/PublicAccessServiceTests.cs
@@ -8,9 +8,9 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Services
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- public class PublicAccessServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
+ public class PublicAccessServiceTests : TestWithSomeContentBase
{
[Test]
public void Can_Add_New_Entry()
diff --git a/src/Umbraco.Tests/Services/RelationServiceTests.cs b/src/Umbraco.Tests/Services/RelationServiceTests.cs
index 93eedf3da9..074850da91 100644
--- a/src/Umbraco.Tests/Services/RelationServiceTests.cs
+++ b/src/Umbraco.Tests/Services/RelationServiceTests.cs
@@ -6,9 +6,9 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Services
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture, RequiresSTA]
- public class RelationServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
+ public class RelationServiceTests : TestWithSomeContentBase
{
[Test]
public void Can_Create_RelationType_Without_Name()
diff --git a/src/Umbraco.Tests/Services/TagServiceTests.cs b/src/Umbraco.Tests/Services/TagServiceTests.cs
index 06344d2172..1a43a0b7f9 100644
--- a/src/Umbraco.Tests/Services/TagServiceTests.cs
+++ b/src/Umbraco.Tests/Services/TagServiceTests.cs
@@ -12,9 +12,9 @@ namespace Umbraco.Tests.Services
/// This is more of an integration test as it involves multiple layers
/// as well as configuration.
///
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- public class TagServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
+ public class TagServiceTests : TestWithSomeContentBase
{
[Test]
public void TagList_Contains_NodeCount()
diff --git a/src/Umbraco.Tests/Services/BaseServiceTest.cs b/src/Umbraco.Tests/Services/TestWithSomeContentBase.cs
similarity index 89%
rename from src/Umbraco.Tests/Services/BaseServiceTest.cs
rename to src/Umbraco.Tests/Services/TestWithSomeContentBase.cs
index 2a2ff736fa..77e4826e25 100644
--- a/src/Umbraco.Tests/Services/BaseServiceTest.cs
+++ b/src/Umbraco.Tests/Services/TestWithSomeContentBase.cs
@@ -1,50 +1,48 @@
-using System;
-using System.Threading;
-using NUnit.Framework;
-using Umbraco.Core.Models;
-using Umbraco.Tests.TestHelpers;
-using Umbraco.Tests.TestHelpers.Entities;
-
-namespace Umbraco.Tests.Services
-{
- [TestFixture, RequiresSTA]
- public abstract class BaseServiceTest : TestWithDatabaseBase
- {
- public override void SetUp()
- {
- base.SetUp();
-
- CreateTestData();
- }
-
- public virtual void CreateTestData()
- {
- //NOTE Maybe not the best way to create/save test data as we are using the services, which are being tested.
-
- //Create and Save ContentType "umbTextpage" -> 1045
- ContentType contentType = MockedContentTypes.CreateSimpleContentType("umbTextpage", "Textpage");
- contentType.Key = new Guid("1D3A8E6E-2EA9-4CC1-B229-1AEE19821522");
- ServiceContext.ContentTypeService.Save(contentType);
-
- //Create and Save Content "Homepage" based on "umbTextpage" -> 1046
- Content textpage = MockedContent.CreateSimpleContent(contentType);
- textpage.Key = new Guid("B58B3AD4-62C2-4E27-B1BE-837BD7C533E0");
- ServiceContext.ContentService.Save(textpage, 0);
-
- //Create and Save Content "Text Page 1" based on "umbTextpage" -> 1047
- Content subpage = MockedContent.CreateSimpleContent(contentType, "Text Page 1", textpage.Id);
- subpage.ReleaseDate = DateTime.Now.AddMinutes(-5);
- subpage.ChangePublishedState(PublishedState.Saving);
- ServiceContext.ContentService.Save(subpage, 0);
-
- //Create and Save Content "Text Page 1" based on "umbTextpage" -> 1048
- Content subpage2 = MockedContent.CreateSimpleContent(contentType, "Text Page 2", textpage.Id);
- ServiceContext.ContentService.Save(subpage2, 0);
-
- //Create and Save Content "Text Page Deleted" based on "umbTextpage" -> 1049
- Content trashed = MockedContent.CreateSimpleContent(contentType, "Text Page Deleted", -20);
- trashed.Trashed = true;
- ServiceContext.ContentService.Save(trashed, 0);
- }
- }
+using System;
+using NUnit.Framework;
+using Umbraco.Core.Models;
+using Umbraco.Tests.TestHelpers;
+using Umbraco.Tests.TestHelpers.Entities;
+
+namespace Umbraco.Tests.Services
+{
+ [TestFixture, RequiresSTA]
+ public abstract class TestWithSomeContentBase : TestWithDatabaseBase
+ {
+ public override void SetUp()
+ {
+ base.SetUp();
+ CreateTestData();
+ }
+
+ public virtual void CreateTestData()
+ {
+ //NOTE Maybe not the best way to create/save test data as we are using the services, which are being tested.
+
+ //Create and Save ContentType "umbTextpage" -> 1045
+ ContentType contentType = MockedContentTypes.CreateSimpleContentType("umbTextpage", "Textpage");
+ contentType.Key = new Guid("1D3A8E6E-2EA9-4CC1-B229-1AEE19821522");
+ ServiceContext.ContentTypeService.Save(contentType);
+
+ //Create and Save Content "Homepage" based on "umbTextpage" -> 1046
+ Content textpage = MockedContent.CreateSimpleContent(contentType);
+ textpage.Key = new Guid("B58B3AD4-62C2-4E27-B1BE-837BD7C533E0");
+ ServiceContext.ContentService.Save(textpage, 0);
+
+ //Create and Save Content "Text Page 1" based on "umbTextpage" -> 1047
+ Content subpage = MockedContent.CreateSimpleContent(contentType, "Text Page 1", textpage.Id);
+ subpage.ReleaseDate = DateTime.Now.AddMinutes(-5);
+ subpage.ChangePublishedState(PublishedState.Saving);
+ ServiceContext.ContentService.Save(subpage, 0);
+
+ //Create and Save Content "Text Page 1" based on "umbTextpage" -> 1048
+ Content subpage2 = MockedContent.CreateSimpleContent(contentType, "Text Page 2", textpage.Id);
+ ServiceContext.ContentService.Save(subpage2, 0);
+
+ //Create and Save Content "Text Page Deleted" based on "umbTextpage" -> 1049
+ Content trashed = MockedContent.CreateSimpleContent(contentType, "Text Page Deleted", -20);
+ trashed.Trashed = true;
+ ServiceContext.ContentService.Save(trashed, 0);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Umbraco.Tests/Services/ThreadSafetyServiceTest.cs b/src/Umbraco.Tests/Services/ThreadSafetyServiceTest.cs
index 6bda8311de..172a5b0968 100644
--- a/src/Umbraco.Tests/Services/ThreadSafetyServiceTest.cs
+++ b/src/Umbraco.Tests/Services/ThreadSafetyServiceTest.cs
@@ -23,9 +23,9 @@ using Umbraco.Core.DI;
namespace Umbraco.Tests.Services
{
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- public class ThreadSafetyServiceTest : TestWithDatabaseBase
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
+ public class ThreadSafetyServiceTest : TestWithDatabaseBase
{
//private IDatabaseUnitOfWorkProvider _uowProvider;
//private PerThreadSqlCeDatabaseFactory _dbFactory;
diff --git a/src/Umbraco.Tests/Services/UserServiceTests.cs b/src/Umbraco.Tests/Services/UserServiceTests.cs
index 3ba0981249..4c8f5fd08b 100644
--- a/src/Umbraco.Tests/Services/UserServiceTests.cs
+++ b/src/Umbraco.Tests/Services/UserServiceTests.cs
@@ -14,9 +14,9 @@ namespace Umbraco.Tests.Services
///
/// Tests covering the UserService
///
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture, RequiresSTA]
- public class UserServiceTests : BaseServiceTest
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
+ public class UserServiceTests : TestWithSomeContentBase
{
[Test]
public void UserService_Get_User_Permissions_For_Unassigned_Permission_Nodes()
diff --git a/src/Umbraco.Tests/Strings/CmsHelperCasingTests.cs b/src/Umbraco.Tests/Strings/CmsHelperCasingTests.cs
index eaa01da9ba..dd4ca6035b 100644
--- a/src/Umbraco.Tests/Strings/CmsHelperCasingTests.cs
+++ b/src/Umbraco.Tests/Strings/CmsHelperCasingTests.cs
@@ -6,7 +6,7 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Strings
{
[TestFixture]
- public class CmsHelperCasingTests : BaseTestBase
+ public class CmsHelperCasingTests : UmbracoTestBase
{
[SetUp]
public void Setup()
diff --git a/src/Umbraco.Tests/Strings/DefaultShortStringHelperTests.cs b/src/Umbraco.Tests/Strings/DefaultShortStringHelperTests.cs
index 630bc4c8b7..81c19cdd2e 100644
--- a/src/Umbraco.Tests/Strings/DefaultShortStringHelperTests.cs
+++ b/src/Umbraco.Tests/Strings/DefaultShortStringHelperTests.cs
@@ -16,7 +16,7 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Strings
{
[TestFixture]
- public class DefaultShortStringHelperTests : BaseTestBase
+ public class DefaultShortStringHelperTests : UmbracoTestBase
{
private DefaultShortStringHelper _helper;
@@ -24,11 +24,6 @@ namespace Umbraco.Tests.Strings
{
base.SetUp();
- // NOTE: it is not possible to configure the helper once it has been assigned
- // to the resolver and resolution has frozen. but, obviously, it is possible
- // to configure filters and then to alter these filters after resolution has
- // frozen. beware, nothing is thread-safe in-there!
-
// NOTE pre-filters runs _before_ Recode takes place
// so there still may be utf8 chars even though you want ascii
@@ -74,9 +69,8 @@ namespace Umbraco.Tests.Strings
BreakTermsOnUpper = true
}));
- var container = new ServiceContainer();
- container.ConfigureUmbracoCore();
- container.Register(_ => _helper);
+ // fixme - move to a "compose" thing?
+ Container.RegisterSingleton(f => _helper);
}
private static readonly Regex FrenchElisionsRegex = new Regex("\\b(c|d|j|l|m|n|qu|s|t)('|\u8217)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
@@ -317,7 +311,7 @@ namespace Umbraco.Tests.Strings
Separator = '*'
}));
Assert.AreEqual("house*2", helper.CleanString("house (2)", CleanStringType.Alias));
-
+
// FIXME but for a filename we want to keep them!
// FIXME and what about a url?
}
@@ -551,7 +545,7 @@ namespace Umbraco.Tests.Strings
{
var output = _helper.SplitPascalCasing(input, ' ');
Assert.AreEqual(expected, output);
-
+
output = _helper.SplitPascalCasing(input, '*');
expected = expected.Replace(' ', '*');
Assert.AreEqual(expected, output);
diff --git a/src/Umbraco.Tests/Strings/StringExtensionsTests.cs b/src/Umbraco.Tests/Strings/StringExtensionsTests.cs
index 6ac9a5c47a..1118bc036e 100644
--- a/src/Umbraco.Tests/Strings/StringExtensionsTests.cs
+++ b/src/Umbraco.Tests/Strings/StringExtensionsTests.cs
@@ -1,7 +1,6 @@
using System;
using System.Diagnostics;
using System.Globalization;
-using LightInject;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.DI;
@@ -11,15 +10,14 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Strings
{
[TestFixture]
- public class StringExtensionsTests : BaseTestBase
+ public class StringExtensionsTests : UmbracoTestBase
{
public override void SetUp()
{
base.SetUp();
- var container = new ServiceContainer();
- container.ConfigureUmbracoCore();
- container.RegisterSingleton(_ => new MockShortStringHelper());
+ // fixme - in "compose"?
+ Container.RegisterSingleton(_ => new MockShortStringHelper());
}
[Test]
diff --git a/src/Umbraco.Tests/Strings/StringValidationTests.cs b/src/Umbraco.Tests/Strings/StringValidationTests.cs
index b887c96ec0..6ce2e34547 100644
--- a/src/Umbraco.Tests/Strings/StringValidationTests.cs
+++ b/src/Umbraco.Tests/Strings/StringValidationTests.cs
@@ -5,7 +5,7 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Strings
{
[TestFixture]
- public class StringValidationTests : BaseTestBase
+ public class StringValidationTests : UmbracoTestBase
{
[Test]
public void Validate_Email_Address()
diff --git a/src/Umbraco.Tests/Strings/StylesheetHelperTests.cs b/src/Umbraco.Tests/Strings/StylesheetHelperTests.cs
index ecfce1351b..73bdfbed72 100644
--- a/src/Umbraco.Tests/Strings/StylesheetHelperTests.cs
+++ b/src/Umbraco.Tests/Strings/StylesheetHelperTests.cs
@@ -8,7 +8,7 @@ using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Strings
{
[TestFixture]
- public class StylesheetHelperTests : BaseTestBase
+ public class StylesheetHelperTests : UmbracoTestBase
{
[Test]
public void Replace_Rule()
diff --git a/src/Umbraco.Tests/TestHelpers/BaseTestBase.cs b/src/Umbraco.Tests/TestHelpers/BaseTestBase.cs
deleted file mode 100644
index 8b19fa1c8c..0000000000
--- a/src/Umbraco.Tests/TestHelpers/BaseTestBase.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using NUnit.Framework;
-using Umbraco.Core.DI;
-
-namespace Umbraco.Tests.TestHelpers
-{
- ///
- /// Provides the top-level base class for all Umbraco tests.
- ///
- ///
- /// Ensures that Current is properly resetted before and after each test executes.
- /// Defines the SetUp and TearDown methods with proper attributes (not needed on overrides).
- /// Attributes rules: use [TestFixture] on concrete fixtures only, and don't repeat the [SetUp] and [TearDown] attributes.
- ///
- public abstract class BaseTestBase
- {
- [SetUp]
- public virtual void SetUp()
- {
- // should not need this if all other tests were clean
- // but hey, never know, better avoid garbage-in
- Current.Reset();
- }
-
- [TearDown]
- public virtual void TearDown()
- {
- Current.Reset();
- }
- }
-}
diff --git a/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs b/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs
index f5b2420c44..b75e2fb49a 100644
--- a/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs
+++ b/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs
@@ -65,9 +65,9 @@ namespace Umbraco.Tests.TestHelpers
{
return new FacadeRouter(
TestObjects.GetUmbracoSettings().WebRouting,
- contentFinders ?? new ContentFinderCollection(Enumerable.Empty()),
+ contentFinders ?? new ContentFinderCollection(Enumerable.Empty()),
new FakeLastChanceFinder(),
- container?.TryGetInstance() ?? new ServiceContext(),
+ container?.TryGetInstance() ?? new ServiceContext(),
new ProfilingLogger(Mock.Of(), Mock.Of()));
}
}
diff --git a/src/Umbraco.Tests/TestHelpers/DatabaseTestBehaviorAttribute.cs b/src/Umbraco.Tests/TestHelpers/DatabaseTestBehaviorAttribute.cs
deleted file mode 100644
index a6bee4515c..0000000000
--- a/src/Umbraco.Tests/TestHelpers/DatabaseTestBehaviorAttribute.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-
-namespace Umbraco.Tests.TestHelpers
-{
- [AttributeUsage(AttributeTargets.Class)]
- public sealed class DatabaseTestBehaviorAttribute : Attribute
- {
- public DatabaseBehavior Behavior { get; private set; }
-
- public DatabaseTestBehaviorAttribute(DatabaseBehavior behavior)
- {
- Behavior = behavior;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Umbraco.Tests/TestHelpers/RequiresAutoMapperMappingsAttribute.cs b/src/Umbraco.Tests/TestHelpers/RequiresAutoMapperMappingsAttribute.cs
deleted file mode 100644
index 3dc28d24e1..0000000000
--- a/src/Umbraco.Tests/TestHelpers/RequiresAutoMapperMappingsAttribute.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System;
-
-namespace Umbraco.Tests.TestHelpers
-{
- [AttributeUsage(AttributeTargets.Class)]
- public sealed class RequiresAutoMapperMappingsAttribute : Attribute
- {
- }
-}
\ No newline at end of file
diff --git a/src/Umbraco.Tests/TestHelpers/Settable.cs b/src/Umbraco.Tests/TestHelpers/Settable.cs
new file mode 100644
index 0000000000..71c697f660
--- /dev/null
+++ b/src/Umbraco.Tests/TestHelpers/Settable.cs
@@ -0,0 +1,94 @@
+using System;
+
+namespace Umbraco.Tests.TestHelpers
+{
+ // fixme - belongs to Core?
+
+ ///
+ /// Represents a value that can be assigned a value.
+ ///
+ /// The type of the value
+ public class Settable
+ {
+ private T _value;
+
+ ///
+ /// Assigns a value to this instance.
+ ///
+ /// The value.
+ public void Set(T value)
+ {
+ HasValue = true;
+ _value = value;
+ }
+
+ ///
+ /// Assigns a value to this instance by copying the value
+ /// of another instance, if the other instance has a value.
+ ///
+ /// The other instance.
+ public void Set(Settable other)
+ {
+ // set only if has value else don't change anything
+ if (other.HasValue) Set(other.Value);
+ }
+
+ ///
+ /// Clears the value.
+ ///
+ public void Clear()
+ {
+ HasValue = false;
+ _value = default (T);
+ }
+
+ ///
+ /// Gets a value indicating whether a value has been assigned to this instance.
+ ///
+ public bool HasValue { get; private set; }
+
+ ///
+ /// Gets the value assigned to this instance.
+ ///
+ /// An exception is thrown if the HasValue property is false.
+ /// No value has been assigned to this instance.
+ public T Value
+ {
+ get
+ {
+ if (HasValue == false)
+ throw new InvalidOperationException("The HasValue property is false.");
+ return _value;
+ }
+ }
+
+ ///
+ /// Gets the value assigned to this instance, if a value has been assigned,
+ /// otherwise the default value of .
+ ///
+ /// The value assigned to this instance, if a value has been assigned,
+ /// else the default value of .
+ public T ValueOrDefault()
+ {
+ return HasValue ? _value : default(T);
+ }
+
+ ///
+ /// Gets the value assigned to this instance, if a value has been assigned,
+ /// otherwise a specified default value.
+ ///
+ /// The default value.
+ /// The value assigned to this instance, if a value has been assigned,
+ /// else .
+ public T ValueOrDefault(T defaultValue)
+ {
+ return HasValue ? _value : defaultValue;
+ }
+
+ ///
+ public override string ToString()
+ {
+ return HasValue ? _value.ToString() : "void";
+ }
+ }
+}
diff --git a/src/Umbraco.Tests/TestHelpers/TestWithApplicationBase.cs b/src/Umbraco.Tests/TestHelpers/TestWithApplicationBase.cs
index 7cd369925e..1a80ef46ad 100644
--- a/src/Umbraco.Tests/TestHelpers/TestWithApplicationBase.cs
+++ b/src/Umbraco.Tests/TestHelpers/TestWithApplicationBase.cs
@@ -1,19 +1,13 @@
using System;
-using System.IO;
using System.Linq;
-using System.Reflection;
-using AutoMapper;
-using LightInject;
using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
-using Umbraco.Core.Models.Mapping;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.SqlSyntax;
-using Umbraco.Core.Persistence.UnitOfWork;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Strings;
using Umbraco.Core.DI;
@@ -22,7 +16,6 @@ using Umbraco.Core.Events;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Plugins;
using Umbraco.Core.Services;
-using Umbraco.Web.DependencyInjection;
using Umbraco.Web.Services;
using UmbracoExamine;
@@ -38,21 +31,16 @@ namespace Umbraco.Tests.TestHelpers
/// Does *not* create a database.
///
[TestFixture]
+ [UmbracoTest(AutoMapper = true, ResetPluginManager = false)]
public abstract class TestWithApplicationBase : TestWithSettingsBase
{
- private static PluginManager _pluginManager;
+ protected ILogger Logger => Container.GetInstance();
- // tests shouldn't use IoC, but for all these tests inheriting from this class are integration tests
- // and the number of these will hopefully start getting greatly reduced now that most things are mockable.
- protected IServiceContainer Container { get; private set; }
+ protected IProfiler Profiler => Container.GetInstance();
- protected ILogger Logger { get; private set; }
+ protected ProfilingLogger ProfilingLogger => Container.GetInstance();
- protected IProfiler Profiler { get; private set; }
-
- protected ProfilingLogger ProfilingLogger { get; private set; }
-
- protected CacheHelper CacheHelper { get; private set; }
+ protected CacheHelper CacheHelper => Container.GetInstance();
protected virtual ISqlSyntaxProvider SqlSyntax => new SqlCeSyntaxProvider();
@@ -67,28 +55,17 @@ namespace Umbraco.Tests.TestHelpers
///
protected virtual bool PluginManagerResetRequired => false;
- [TestFixtureSetUp]
- public void InitializeFixture()
- {
- Logger = new Logger(new FileInfo(TestHelper.MapPathForTest("~/unit-test-log4net.config")));
- Profiler = new LogProfiler(Logger);
- ProfilingLogger = new ProfilingLogger(Logger, Profiler);
- }
-
public override void SetUp()
{
base.SetUp();
- var container = new ServiceContainer();
- container.ConfigureUmbracoCore();
- Container = container;
-
TestHelper.InitializeContentDirectories();
- CacheHelper = CreateCacheHelper();
- InitializeLegacyMappingsForCoreEditors();
- SetupPluginManager();
- Compose();
- InitializeAutoMapper();
+
+ // initialize legacy mapings for core editors
+ // create the legacy prop-eds mapping
+ if (LegacyPropertyEditorIdToAliasConverter.Count() == 0)
+ LegacyPropertyEditorIdToAliasConverter.CreateMappingsForCoreEditors();
+
MoreSetUp();
}
@@ -98,29 +75,14 @@ namespace Umbraco.Tests.TestHelpers
TestHelper.CleanContentDirectories();
TestHelper.CleanUmbracoSettingsConfig();
-
- ResetPluginManager();
- Container.Dispose();
}
- protected virtual void Compose()
+ protected override void Compose()
{
+ base.Compose();
+
var settings = SettingsForTests.GetDefault();
- // basic things
- Container.RegisterSingleton(factory => Logger);
- Container.RegisterSingleton(factory => Profiler);
- Container.RegisterSingleton(factory => ProfilingLogger);
-
- Container.Register(factory => CacheHelper);
- Container.Register(factory => CacheHelper.RuntimeCache);
-
- // register mappers
- Container.RegisterFrom();
- Container.RegisterFrom();
-
- Container.RegisterInstance(_pluginManager);
-
// default Datalayer/Repositories/SQL/Database/etc...
Container.RegisterFrom();
@@ -172,59 +134,12 @@ namespace Umbraco.Tests.TestHelpers
// composition root is doing weird things, fix
Container.RegisterSingleton();
Container.RegisterSingleton();
- }
- private static void InitializeLegacyMappingsForCoreEditors()
- {
- // create the legacy prop-eds mapping
- if (LegacyPropertyEditorIdToAliasConverter.Count() == 0)
- LegacyPropertyEditorIdToAliasConverter.CreateMappingsForCoreEditors();
- }
+ Container.RegisterSingleton(f => new PropertyEditorCollection(Enumerable.Empty()));
+ }
- // initialize automapper if required - takes time so don't do it unless required
- private void InitializeAutoMapper()
- {
- if (GetType().GetCustomAttribute(false) == null) return;
-
- Mapper.Initialize(configuration =>
- {
- var mappers = Container.GetAllInstances();
- foreach (var mapper in mappers)
- mapper.ConfigureMappings(configuration);
- });
- }
-
- protected virtual void ResetPluginManager()
- {
- if (PluginManagerResetRequired)
- _pluginManager = null;
- }
-
- protected virtual CacheHelper CreateCacheHelper()
- {
- return CacheHelper.CreateDisabledCacheHelper();
- }
-
- protected virtual void SetupPluginManager()
- {
- if (_pluginManager == null || PluginManagerResetRequired)
- {
- _pluginManager = new PluginManager(CacheHelper.RuntimeCache, ProfilingLogger, false)
- {
- AssembliesToScan = new[]
- {
- Assembly.Load("Umbraco.Core"),
- Assembly.Load("umbraco"),
- Assembly.Load("Umbraco.Tests"),
- Assembly.Load("cms"),
- Assembly.Load("controls"),
- }
- };
- }
- }
-
- // fixme - rename & refactor
- protected virtual void MoreSetUp()
+ // fixme - rename & refactor
+ protected virtual void MoreSetUp()
{ }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs
index 323c74ae60..75b64d4811 100644
--- a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs
+++ b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs
@@ -96,7 +96,7 @@ namespace Umbraco.Tests.TestHelpers
Container.RegisterSingleton(f =>
{
- if (DatabaseTestBehavior == DatabaseBehavior.NoDatabasePerFixture)
+ if (Options.Database == UmbracoTestOptions.Database.None)
return TestObjects.GetDatabaseFactoryMock();
var sqlSyntaxProviders = new[] { new SqlCeSyntaxProvider() };
@@ -118,10 +118,10 @@ namespace Umbraco.Tests.TestHelpers
_isFirstInFixture = false;
_isFirstInSession = false;
- using (ProfilingLogger.TraceDuration("teardown"))
+ using (ProfilingLogger.TraceDuration("teardown")) // fixme move that one up
{
- if (DatabaseTestBehavior == DatabaseBehavior.NewDbFileAndSchemaPerTest)
- RemoveDatabaseFile(Core.DI.Current.HasContainer ? Core.DI.Current.DatabaseContext.Database : null);
+ if (Options.Database == UmbracoTestOptions.Database.NewSchemaPerTest)
+ RemoveDatabaseFile(Core.DI.Current.HasContainer ? Core.DI.Current.Container.TryGetInstance()?.Database : null);
AppDomain.CurrentDomain.SetData("DataDirectory", null);
@@ -221,15 +221,6 @@ namespace Umbraco.Tests.TestHelpers
// return _appContext;
//}
- protected DatabaseBehavior DatabaseTestBehavior
- {
- get
- {
- var att = GetType().GetCustomAttribute(false);
- return att?.Behavior ?? DatabaseBehavior.NoDatabasePerFixture;
- }
- }
-
protected virtual ISqlSyntaxProvider GetSyntaxProvider()
{
return new SqlCeSyntaxProvider();
@@ -259,7 +250,7 @@ namespace Umbraco.Tests.TestHelpers
///
protected virtual void CreateSqlCeDatabase()
{
- if (DatabaseTestBehavior == DatabaseBehavior.NoDatabasePerFixture)
+ if (Options.Database == UmbracoTestOptions.Database.None)
return;
var path = TestHelper.CurrentAssemblyDirectory;
@@ -281,9 +272,9 @@ namespace Umbraco.Tests.TestHelpers
//if this is the first test in the session, always ensure a new db file is created
if (_isFirstInSession
|| File.Exists(_databasePath) == false
- || DatabaseTestBehavior == DatabaseBehavior.NewDbFileAndSchemaPerTest
- || DatabaseTestBehavior == DatabaseBehavior.EmptyDbFilePerTest
- || (_isFirstInFixture && DatabaseTestBehavior == DatabaseBehavior.NewDbFileAndSchemaPerFixture))
+ || Options.Database == UmbracoTestOptions.Database.NewSchemaPerTest
+ || Options.Database == UmbracoTestOptions.Database.NewEmptyPerTest
+ || (_isFirstInFixture && Options.Database == UmbracoTestOptions.Database.NewSchemaPerFixture))
{
using (ProfilingLogger.TraceDuration("Remove database file"))
{
@@ -299,7 +290,7 @@ namespace Umbraco.Tests.TestHelpers
//Create the Sql CE database
using (ProfilingLogger.TraceDuration("Create database file"))
{
- if (DatabaseTestBehavior != DatabaseBehavior.EmptyDbFilePerTest && _databaseBytes != null)
+ if (Options.Database != UmbracoTestOptions.Database.NewEmptyPerTest && _databaseBytes != null)
{
File.WriteAllBytes(_databasePath, _databaseBytes);
}
@@ -327,11 +318,8 @@ namespace Umbraco.Tests.TestHelpers
// ensure we have a FacadeService
if (_facadeService == null)
{
- var behavior = GetType().GetCustomAttribute(false);
var cache = new NullCacheProvider();
- var enableRepositoryEvents = behavior != null && behavior.EnableRepositoryEvents;
-
ContentTypesCache = new PublishedContentTypeCache(
Core.DI.Current.Services.ContentTypeService,
Core.DI.Current.Services.MediaTypeService,
@@ -343,7 +331,7 @@ namespace Umbraco.Tests.TestHelpers
var service = new FacadeService(
Core.DI.Current.Services,
UowProvider,
- cache, facadeAccessor, Core.DI.Current.Logger, ContentTypesCache, null, true, enableRepositoryEvents);
+ cache, facadeAccessor, Core.DI.Current.Logger, ContentTypesCache, null, true, Options.FacadeServiceRepositoryEvents);
// initialize PublishedCacheService content with an Xml source
service.XmlStore.GetXmlDocument = () =>
@@ -364,7 +352,7 @@ namespace Umbraco.Tests.TestHelpers
///
protected virtual void InitializeDatabase()
{
- if (DatabaseTestBehavior == DatabaseBehavior.NoDatabasePerFixture || DatabaseTestBehavior == DatabaseBehavior.EmptyDbFilePerTest)
+ if (Options.Database == UmbracoTestOptions.Database.None || Options.Database == UmbracoTestOptions.Database.NewEmptyPerTest)
return;
//create the schema and load default data if:
@@ -374,8 +362,8 @@ namespace Umbraco.Tests.TestHelpers
if (_databaseBytes == null &&
(_isFirstInSession
- || DatabaseTestBehavior == DatabaseBehavior.NewDbFileAndSchemaPerTest
- || (_isFirstInFixture && DatabaseTestBehavior == DatabaseBehavior.NewDbFileAndSchemaPerFixture)))
+ || Options.Database == UmbracoTestOptions.Database.NewSchemaPerTest
+ || (_isFirstInFixture && Options.Database == UmbracoTestOptions.Database.NewSchemaPerFixture)))
{
var database = Core.DI.Current.DatabaseContext.Database;
var schemaHelper = new DatabaseSchemaHelper(database, Logger);
diff --git a/src/Umbraco.Tests/TestHelpers/TestWithSettingsBase.cs b/src/Umbraco.Tests/TestHelpers/TestWithSettingsBase.cs
index 3b65582fe9..a1fb6e791c 100644
--- a/src/Umbraco.Tests/TestHelpers/TestWithSettingsBase.cs
+++ b/src/Umbraco.Tests/TestHelpers/TestWithSettingsBase.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Tests.TestHelpers
/// Ensures that SettingsForTests is property resetted before and after each test executes.
/// Sets a test Umbraco context accessor.
///
- public abstract class TestWithSettingsBase : BaseTestBase
+ public abstract class TestWithSettingsBase : UmbracoTestBase
{
public override void SetUp()
{
diff --git a/src/Umbraco.Tests/TestHelpers/UmbracoTestAttribute.cs b/src/Umbraco.Tests/TestHelpers/UmbracoTestAttribute.cs
new file mode 100644
index 0000000000..b18b3d1a3e
--- /dev/null
+++ b/src/Umbraco.Tests/TestHelpers/UmbracoTestAttribute.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Linq;
+using System.Reflection;
+
+namespace Umbraco.Tests.TestHelpers
+{
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, /*AllowMultiple = false,*/ Inherited = false)]
+ public class UmbracoTestAttribute : Attribute
+ {
+ private readonly Settable _autoMapper = new Settable();
+ public bool AutoMapper { get { return _autoMapper.ValueOrDefault(false); } set { _autoMapper.Set(value);} }
+
+ private readonly Settable _resetPluginManager = new Settable();
+ public bool ResetPluginManager { get { return _resetPluginManager.ValueOrDefault(false); } set { _resetPluginManager.Set(value); } }
+
+ private readonly Settable _facadeServiceRepositoryEvents = new Settable();
+ public bool FacadeServiceRepositoryEvents { get { return _facadeServiceRepositoryEvents.ValueOrDefault(false); } set { _facadeServiceRepositoryEvents.Set(value); } }
+
+ private readonly Settable _logger = new Settable();
+ public UmbracoTestOptions.Logger Logger { get { return _logger.ValueOrDefault(UmbracoTestOptions.Logger.Mock); } set { _logger.Set(value); } }
+
+ private readonly Settable _database = new Settable();
+ public UmbracoTestOptions.Database Database { get { return _database.ValueOrDefault(UmbracoTestOptions.Database.None); } set { _database.Set(value); } }
+
+ public static UmbracoTestAttribute Get(MethodInfo method)
+ {
+ var attr = ((UmbracoTestAttribute[]) method.GetCustomAttributes(typeof (UmbracoTestAttribute), true)).FirstOrDefault();
+ var type = method.DeclaringType;
+ return Get(type, attr);
+ }
+
+ public static UmbracoTestAttribute Get(Type type)
+ {
+ return Get(type, null);
+ }
+
+ private static UmbracoTestAttribute Get(Type type, UmbracoTestAttribute attr)
+ {
+ while (type != null && type != typeof(object))
+ {
+ var attr2 = ((UmbracoTestAttribute[]) type.GetCustomAttributes(typeof (UmbracoTestAttribute), true)).FirstOrDefault();
+ if (attr2 != null)
+ attr = attr == null ? attr2 : attr2.Merge(attr);
+ type = type.BaseType;
+ }
+ return attr ?? new UmbracoTestAttribute();
+ }
+
+ private UmbracoTestAttribute Merge(UmbracoTestAttribute other)
+ {
+ _autoMapper.Set(other._autoMapper);
+ _resetPluginManager.Set(other._resetPluginManager);
+ _facadeServiceRepositoryEvents.Set(other._facadeServiceRepositoryEvents);
+ _logger.Set(other._logger);
+ _database.Set(other._database);
+ return this;
+ }
+ }
+}
diff --git a/src/Umbraco.Tests/TestHelpers/UmbracoTestBase.cs b/src/Umbraco.Tests/TestHelpers/UmbracoTestBase.cs
new file mode 100644
index 0000000000..ab9bda6d11
--- /dev/null
+++ b/src/Umbraco.Tests/TestHelpers/UmbracoTestBase.cs
@@ -0,0 +1,198 @@
+using System.IO;
+using System.Reflection;
+using AutoMapper;
+using LightInject;
+using Moq;
+using NUnit.Framework;
+using Umbraco.Core;
+using Umbraco.Core.Cache;
+using Umbraco.Core.Components;
+using Umbraco.Core.DI;
+using Umbraco.Core.Logging;
+using Umbraco.Core.Models.Mapping;
+using Umbraco.Core.Plugins;
+using Umbraco.Web.DI;
+
+namespace Umbraco.Tests.TestHelpers
+{
+ ///
+ /// Provides the top-level base class for all Umbraco integration tests.
+ ///
+ ///
+ /// True unit tests do not need to inherit from this class, but most of Umbraco tests
+ /// are not true unit tests but integration tests requiring services, databases, etc. This class
+ /// provides all the necessary environment, through DI. Yes, DI is bad in tests - unit tests.
+ /// But it is OK in integration tests.
+ ///
+ public abstract class UmbracoTestBase
+ {
+ // this class
+ // ensures that Current is properly resetted
+ // ensures that a service container is properly initialized and disposed
+ // compose the required dependencies according to test options (UmbracoTestAttribute)
+ //
+ // everything is virtual (because, why not?)
+ // 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
+ // - test runs
+ // - TearDown() // when overriding, clear you own stuff *then* call base.TearDown()
+ //
+ // about attributes
+ //
+ // this class defines the SetUp and TearDown methods, with proper attributes, and
+ // these attributes are *inherited* so classes inheriting from this class should *not*
+ // add the attributes to SetUp nor TearDown again
+ //
+ // this class is *not* marked with the TestFeature attribute because it is *not* a
+ // test feature, and no test "base" class should be. only actual test feature classes
+ // should be marked with that attribute.
+
+ protected ServiceContainer Container { get; private set; }
+
+ protected UmbracoTestAttribute Options { get; private set; }
+
+ private static PluginManager _pluginManager;
+ private static bool _firstDatabaseInSession = true;
+ private bool _firstDatabaseInFixture = true;
+
+ [SetUp]
+ public virtual void SetUp()
+ {
+ // should not need this if all other tests were clean
+ // but hey, never know, better avoid garbage-in
+ Reset();
+
+ Container = new ServiceContainer();
+ Container.ConfigureUmbracoCore();
+
+ // get/merge the attributes marking the method and/or the classes
+ var testName = TestContext.CurrentContext.Test.Name;
+ var pos = testName.IndexOf('(');
+ if (pos > 0) testName = testName.Substring(0, pos);
+ Options = UmbracoTestAttribute.Get(GetType().GetMethod(testName));
+
+ Compose();
+ Initialize();
+ }
+
+ protected virtual void Compose()
+ {
+ ComposeLogging(Options.Logger);
+ ComposeCacheHelper();
+ ComposeAutoMapper(Options.AutoMapper);
+ ComposePluginManager(Options.ResetPluginManager);
+ ComposeDatabase(Options.Database);
+ // etc
+
+ // not sure really
+ var composition = new Composition(Container, RuntimeLevel.Run);
+ Compose(composition);
+ }
+
+ protected virtual void Compose(Composition composition)
+ { }
+
+ protected virtual void Initialize()
+ {
+ InitializeAutoMapper(Options.AutoMapper);
+ }
+
+ #region Composing
+
+ protected virtual void ComposeLogging(UmbracoTestOptions.Logger option)
+ {
+ if (option == UmbracoTestOptions.Logger.Mock)
+ {
+ Container.RegisterSingleton(f => Mock.Of());
+ Container.RegisterSingleton(f => Mock.Of());
+ }
+ else if (option == UmbracoTestOptions.Logger.Log4Net)
+ {
+ Container.RegisterSingleton(f => new Logger(new FileInfo(TestHelper.MapPathForTest("~/unit-test-log4net.config"))));
+ Container.RegisterSingleton(f => new LogProfiler(f.GetInstance()));
+ }
+
+ Container.RegisterSingleton(f => new ProfilingLogger(f.GetInstance(), f.GetInstance()));
+ }
+
+ protected virtual void ComposeCacheHelper()
+ {
+ Container.RegisterSingleton(f => CacheHelper.CreateDisabledCacheHelper());
+ Container.RegisterSingleton(f => f.GetInstance().RuntimeCache);
+ }
+
+ protected virtual void ComposeAutoMapper(bool configure)
+ {
+ if (configure == false) return;
+
+ Container.RegisterFrom();
+ Container.RegisterFrom();
+ }
+
+ protected virtual void ComposePluginManager(bool reset)
+ {
+ Container.RegisterSingleton(f =>
+ {
+ if (_pluginManager != null && reset == false) return _pluginManager;
+
+ return _pluginManager = new PluginManager(f.GetInstance().RuntimeCache, f.GetInstance(), false)
+ {
+ AssembliesToScan = new[]
+ {
+ Assembly.Load("Umbraco.Core"),
+ Assembly.Load("umbraco"),
+ Assembly.Load("Umbraco.Tests"),
+ Assembly.Load("cms"),
+ Assembly.Load("controls"),
+ }
+ };
+ });
+ }
+
+ protected virtual void ComposeDatabase(UmbracoTestOptions.Database option)
+ {
+ if (option == UmbracoTestOptions.Database.None) return;
+
+ // create the file
+ // create the schema
+
+ }
+
+ #endregion
+
+ #region Initialize
+
+ protected virtual void InitializeAutoMapper(bool configure)
+ {
+ if (configure == false) return;
+
+ Mapper.Initialize(configuration =>
+ {
+ var mappers = Container.GetAllInstances();
+ foreach (var mapper in mappers)
+ mapper.ConfigureMappings(configuration);
+ });
+ }
+
+ #endregion
+
+ #region TearDown and Reset
+
+ [TearDown]
+ public virtual void TearDown()
+ {
+ Reset();
+ }
+
+ protected virtual void Reset()
+ {
+ Current.Reset();
+
+ Container?.Dispose();
+ Container = null;
+ }
+
+ #endregion
+ }
+}
diff --git a/src/Umbraco.Tests/TestHelpers/UmbracoTestOptions.cs b/src/Umbraco.Tests/TestHelpers/UmbracoTestOptions.cs
new file mode 100644
index 0000000000..0cdcb1401e
--- /dev/null
+++ b/src/Umbraco.Tests/TestHelpers/UmbracoTestOptions.cs
@@ -0,0 +1,27 @@
+namespace Umbraco.Tests.TestHelpers
+{
+ public static class UmbracoTestOptions
+ {
+ public enum Logger
+ {
+ // pure mocks
+ Mock,
+ // log4net for tests
+ Log4Net
+ }
+
+ public enum Database
+ {
+ // no database
+ None,
+ // new empty database file for the entire feature
+ NewEmptyPerFixture,
+ // new empty database file per test
+ NewEmptyPerTest,
+ // new database file with schema for the entire feature
+ NewSchemaPerFixture,
+ // new database file with schema per test
+ NewSchemaPerTest
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Tests/TestSetup/FacadeServiceAttribute.cs b/src/Umbraco.Tests/TestSetup/FacadeServiceAttribute.cs
deleted file mode 100644
index fdff6baf88..0000000000
--- a/src/Umbraco.Tests/TestSetup/FacadeServiceAttribute.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-
-namespace Umbraco.Tests.TestSetup
-{
- [AttributeUsage(AttributeTargets.Class)]
- internal sealed class FacadeServiceAttribute : Attribute
- {
- public bool EnableRepositoryEvents { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/Umbraco.Tests/TreesAndSections/ApplicationTreeTest.cs b/src/Umbraco.Tests/TreesAndSections/ApplicationTreeTest.cs
index f04a6efe2c..83fd0f3229 100644
--- a/src/Umbraco.Tests/TreesAndSections/ApplicationTreeTest.cs
+++ b/src/Umbraco.Tests/TreesAndSections/ApplicationTreeTest.cs
@@ -15,8 +15,8 @@ namespace Umbraco.Tests.TreesAndSections
///This is a test class for ApplicationTreeTest and is intended
///to contain all ApplicationTreeTest Unit Tests
///
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture, RequiresSTA]
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class ApplicationTreeTest : TestWithDatabaseBase
{
public override void SetUp()
diff --git a/src/Umbraco.Tests/TreesAndSections/SectionTests.cs b/src/Umbraco.Tests/TreesAndSections/SectionTests.cs
index bd02bb7340..4d087f1a54 100644
--- a/src/Umbraco.Tests/TreesAndSections/SectionTests.cs
+++ b/src/Umbraco.Tests/TreesAndSections/SectionTests.cs
@@ -14,9 +14,8 @@ namespace Umbraco.Tests.TreesAndSections
///This is a test class for ApplicationTest and is intended
///to contain all ApplicationTest Unit Tests
///
- [RequiresAutoMapperMappings]
- [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
[TestFixture]
+ [UmbracoTest(AutoMapper = true, Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class SectionTests : TestWithDatabaseBase
{
protected override void Compose()
diff --git a/src/Umbraco.Tests/TryConvertToTests.cs b/src/Umbraco.Tests/TryConvertToTests.cs
index 5846b4cf62..6f1e876c54 100644
--- a/src/Umbraco.Tests/TryConvertToTests.cs
+++ b/src/Umbraco.Tests/TryConvertToTests.cs
@@ -9,16 +9,16 @@ using Umbraco.Core.DI;
namespace Umbraco.Tests
{
[TestFixture]
- public class TryConvertToTests : BaseTestBase
+ public class TryConvertToTests : UmbracoTestBase
{
public override void SetUp()
{
base.SetUp();
var settings = SettingsForTests.GetDefault();
- var container = new ServiceContainer();
- container.ConfigureUmbracoCore();
- container.RegisterSingleton(_ => new DefaultShortStringHelper(settings));
+
+ // fixme - base should do it!
+ Container.RegisterSingleton(_ => new DefaultShortStringHelper(settings));
}
[Test]
diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj
index 42a5132564..88dc716b2c 100644
--- a/src/Umbraco.Tests/Umbraco.Tests.csproj
+++ b/src/Umbraco.Tests/Umbraco.Tests.csproj
@@ -242,15 +242,17 @@
-
+
+
+
+
-
@@ -489,11 +491,9 @@
-
-
True
@@ -512,7 +512,7 @@
-
+
diff --git a/src/Umbraco.Web/DependencyInjection/WebModelMappersCompositionRoot.cs b/src/Umbraco.Web/DI/WebModelMappersCompositionRoot.cs
similarity index 95%
rename from src/Umbraco.Web/DependencyInjection/WebModelMappersCompositionRoot.cs
rename to src/Umbraco.Web/DI/WebModelMappersCompositionRoot.cs
index e6846c208e..1f3a8be944 100644
--- a/src/Umbraco.Web/DependencyInjection/WebModelMappersCompositionRoot.cs
+++ b/src/Umbraco.Web/DI/WebModelMappersCompositionRoot.cs
@@ -1,7 +1,7 @@
using LightInject;
using Umbraco.Web.Models.Mapping;
-namespace Umbraco.Web.DependencyInjection
+namespace Umbraco.Web.DI
{
public sealed class WebModelMappersCompositionRoot : ICompositionRoot
{
diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs
index fd6ebe552d..88372c9872 100644
--- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs
+++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs
@@ -1269,7 +1269,7 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder";
public void Notify(ContentTypeCacheRefresher.JsonPayload[] payloads)
{
if (_xml == null) return; // not initialized yet!
-
+
// see ContentTypeServiceBase
// in all cases we just want to clear the content type cache
// the type will be reloaded if/when needed
@@ -2062,6 +2062,7 @@ WHERE cmsContentXml.nodeId IN (
{
// every published content item should have a corresponding row in cmsContentXml
// every content item should have a corresponding row in cmsPreviewXml
+ // and that row should have the key="..." attribute
var contentObjectType = Guid.Parse(Constants.ObjectTypes.Document);
var db = unitOfWork.Database;
@@ -2071,7 +2072,7 @@ FROM umbracoNode
JOIN cmsDocument ON (umbracoNode.id=cmsDocument.nodeId and cmsDocument.published=1)
LEFT JOIN cmsContentXml ON (umbracoNode.id=cmsContentXml.nodeId)
WHERE umbracoNode.nodeObjectType=@objType
-AND cmsContentXml.nodeId IS NULL
+AND cmsContentXml.nodeId IS NULL OR cmsContentXml.xml NOT LIKE '% key=""'
", new { objType = contentObjectType });
if (count > 0) return false;
@@ -2080,7 +2081,7 @@ AND cmsContentXml.nodeId IS NULL
FROM umbracoNode
LEFT JOIN cmsPreviewXml ON (umbracoNode.id=cmsPreviewXml.nodeId)
WHERE umbracoNode.nodeObjectType=@objType
-AND cmsPreviewXml.nodeId IS NULL
+AND cmsPreviewXml.nodeId IS NULL OR cmsPreviewXml.xml NOT LIKE '% key=""'
", new { objType = contentObjectType });
return count == 0;
@@ -2102,6 +2103,7 @@ AND cmsPreviewXml.nodeId IS NULL
public bool VerifyMediaXmlLocked(IDatabaseUnitOfWork unitOfWork, IMediaRepository repository)
{
// every non-trashed media item should have a corresponding row in cmsContentXml
+ // and that row should have the key="..." attribute
var mediaObjectType = Guid.Parse(Constants.ObjectTypes.Media);
var db = unitOfWork.Database;
@@ -2111,7 +2113,7 @@ FROM umbracoNode
JOIN cmsDocument ON (umbracoNode.id=cmsDocument.nodeId and cmsDocument.published=1)
LEFT JOIN cmsContentXml ON (umbracoNode.id=cmsContentXml.nodeId)
WHERE umbracoNode.nodeObjectType=@objType
-AND cmsContentXml.nodeId IS NULL
+AND cmsContentXml.nodeId IS NULL OR cmsContentXml.xml NOT LIKE '% key=""'
", new { objType = mediaObjectType });
return count == 0;
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 22996d3c2f..1bfb4935e7 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -172,7 +172,7 @@
-
+
diff --git a/src/Umbraco.Web/WebRuntimeComponent.cs b/src/Umbraco.Web/WebRuntimeComponent.cs
index 61e9864f10..e1ba4068a6 100644
--- a/src/Umbraco.Web/WebRuntimeComponent.cs
+++ b/src/Umbraco.Web/WebRuntimeComponent.cs
@@ -25,7 +25,7 @@ using Umbraco.Core.Profiling;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.PropertyEditors.ValueConverters;
using Umbraco.Core.Services;
-using Umbraco.Web.DependencyInjection;
+using Umbraco.Web.DI;
using Umbraco.Web.Dictionary;
using Umbraco.Web.Editors;
using Umbraco.Web.HealthCheck;