From d19d1b3a18f123b3e85127d68c779e32b93386aa Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 17 Mar 2014 19:38:29 +1100 Subject: [PATCH] Changes database behavior in integration tests to be opt-in, removes the db behavior to have a new schema per fixture, now we only deal in new files + schema per fixture/tests as it was taking longer to uninstall the db tables than just delete the file. --- .../BusinessLogic/DictionaryTest.cs | 541 ------------------ src/Umbraco.Tests/CodeFirst/CodeFirstTests.cs | 1 + .../CodeFirst/StronglyTypedMapperTest.cs | 6 +- src/Umbraco.Tests/GlobalSettingsTests.cs | 4 - src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs | 101 ---- src/Umbraco.Tests/LibraryTests.cs | 4 - .../Membership/DynamicMemberContentTests.cs | 6 +- src/Umbraco.Tests/Models/ContentXmlTest.cs | 1 + src/Umbraco.Tests/Models/MediaXmlTest.cs | 1 + .../Persistence/Auditing/AuditTests.cs | 1 + .../Persistence/DatabaseContextTests.cs | 4 + .../Persistence/PetaPocoExtensionsTest.cs | 1 + .../Repositories/ContentRepositoryTest.cs | 1 + .../Repositories/ContentTypeRepositoryTest.cs | 1 + .../DataTypeDefinitionRepositoryTest.cs | 1 + .../Repositories/DictionaryRepositoryTest.cs | 1 + .../Repositories/LanguageRepositoryTest.cs | 1 + .../Repositories/MediaRepositoryTest.cs | 1 + .../Repositories/MediaTypeRepositoryTest.cs | 1 + .../Repositories/MemberRepositoryTest.cs | 1 + .../Repositories/MemberTypeRepositoryTest.cs | 1 + .../NotificationsRepositoryTest.cs | 1 + .../Repositories/RelationRepositoryTest.cs | 1 + .../RelationTypeRepositoryTest.cs | 1 + .../ServerRegistrationRepositoryTest.cs | 1 + .../Repositories/StylesheetRepositoryTest.cs | 1 + .../Repositories/TemplateRepositoryTest.cs | 1 + .../Repositories/UserRepositoryTest.cs | 1 + .../Repositories/UserTypeRepositoryTest.cs | 1 + .../Persistence/SchemaValidationTest.cs | 1 + .../PublishedContentCacheTests.cs | 1 + .../PublishedMediaCacheTests.cs | 1 + .../DynamicDocumentTestsBase.cs | 5 - .../PublishedContent/DynamicNodeTests.cs | 8 +- .../PublishedContentExtensionTests.cs | 8 +- .../PublishedContentRequestEngineTests.cs | 6 - .../PublishedContent/PublishedContentTests.cs | 5 - .../PublishedContent/PublishedMediaTests.cs | 1 + .../Publishing/PublishingStrategyTests.cs | 1 + .../Routing/ContentFinderByAliasTests.cs | 5 - .../ContentFinderByAliasWithDomainsTests.cs | 6 +- .../Routing/ContentFinderByIdTests.cs | 7 - .../ContentFinderByNiceUrlAndTemplateTests.cs | 1 + .../Routing/ContentFinderByNiceUrlTests.cs | 8 +- .../ContentFinderByNiceUrlWithDomainsTests.cs | 1 + .../ContentFinderByPageIdQueryTests.cs | 8 - .../Routing/DomainsAndCulturesTests.cs | 1 + .../Routing/NiceUrlProviderTests.cs | 1 + .../NiceUrlsProviderWithDomainsTests.cs | 6 +- .../Routing/RenderRouteHandlerTests.cs | 5 +- .../Routing/UrlsWithNestedDomains.cs | 1 + .../Routing/uQueryGetNodeIdByUrlTests.cs | 1 + .../Services/ContentServiceTests.cs | 2 + .../Services/ContentTypeServiceTests.cs | 2 + .../Services/DataTypeServiceTests.cs | 2 + .../Services/EntityServiceTests.cs | 8 +- .../Services/Importing/PackageImportTests.cs | 2 + .../Services/LocalizationServiceTests.cs | 2 + .../Services/MediaServiceTests.cs | 2 + .../Services/MemberServiceTests.cs | 2 + .../Services/MemberTypeServiceTests.cs | 2 + .../Services/PackagingServiceTests.cs | 2 + .../Services/PerformanceTests.cs | 8 +- .../Services/RelationServiceTests.cs | 2 + .../Services/ThreadSafetyServiceTest.cs | 1 + .../Services/UserServiceTests.cs | 1 + .../Surface/PluginControllerAreaTests.cs | 6 +- .../TestHelpers/BaseDatabaseFactoryTest.cs | 51 +- .../TestHelpers/DatabaseBehavior.cs | 15 +- .../DatabaseTestBehaviorAttribute.cs | 15 + src/Umbraco.Tests/Umbraco.Tests.csproj | 3 +- .../UmbracoExamine/ContentServiceTest.cs | 1 + 72 files changed, 114 insertions(+), 791 deletions(-) delete mode 100644 src/Umbraco.Tests/BusinessLogic/DictionaryTest.cs delete mode 100644 src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs create mode 100644 src/Umbraco.Tests/TestHelpers/DatabaseTestBehaviorAttribute.cs diff --git a/src/Umbraco.Tests/BusinessLogic/DictionaryTest.cs b/src/Umbraco.Tests/BusinessLogic/DictionaryTest.cs deleted file mode 100644 index 92f3d34c60..0000000000 --- a/src/Umbraco.Tests/BusinessLogic/DictionaryTest.cs +++ /dev/null @@ -1,541 +0,0 @@ -using NUnit.Framework; -using Umbraco.Core; -using Umbraco.Tests.TestHelpers; -using umbraco.cms.businesslogic; -using System; -using System.Xml; -using umbraco.cms.businesslogic.language; -using umbraco.BusinessLogic; -using System.Linq; - -namespace Umbraco.Tests.BusinessLogic -{ - //TODO: This was ported over from the previous unit tests, need to make them work now :) - - /// - ///This is a test class for Dictionary_DictionaryItemTest and is intended - ///to contain all Dictionary_DictionaryItemTest Unit Tests - /// - [TestFixture, NUnit.Framework.Ignore] - public class DictionaryTest : BaseWebTest - { - public override void Initialize() - { - base.Initialize(); - - CreateNew(); - } - - [Test()] - public void Dictionary_Get_Top_Level_Items() - { - var items = Dictionary.getTopMostItems; - - var d = CreateNew(); - - Assert.AreEqual(items.Count() + 1, Dictionary.getTopMostItems.Count()); - - DeleteItem(d); - } - - /// - /// Creates a new dictionary entry, adds values for all languages assigned, then deletes the - /// entry and ensure that all other data is gone too. - /// - [Test()] - public void Dictionary_Create_Add_Text_And_Delete() - { - var d = CreateNew(); - - //set the values for all languages - var langs = Language.GetAllAsList(); - foreach (var l in langs) - { - var val = "TEST" + Guid.NewGuid().ToString("N"); - d.setValue(l.id, val); - //make sure the values are there - Assert.AreEqual(val, d.Value(l.id)); - } - - DeleteItem(d); - - } - - /// - ///A test for IsTopMostItem - /// - [Test()] - public void Dictionary_IsTopMostItem() - { - var parent = CreateNew(); - - //create a child - var childId = Dictionary.DictionaryItem.addKey("Test" + Guid.NewGuid().ToString("N"), "", parent.key); - Assert.IsTrue(childId > 0); - var child = new Dictionary.DictionaryItem(childId); - Assert.IsTrue(TypeHelper.IsTypeAssignableFrom(child)); - - Assert.IsTrue(parent.IsTopMostItem()); - Assert.IsFalse(child.IsTopMostItem()); - - DeleteItem(child); - DeleteItem(parent); - } - - /// - /// Test the Parent and Children properties and ensures that the relationships work both ways - /// - [Test()] - public void Dictionary_Parent_Child_Relationship() - { - var parent = CreateNew(); - - //create a child - var childId = Dictionary.DictionaryItem.addKey("Test" + Guid.NewGuid().ToString("N"), "", parent.key); - Assert.IsTrue(childId > 0); - var child = new Dictionary.DictionaryItem(childId); - Assert.IsTrue(TypeHelper.IsTypeAssignableFrom(child)); - - //set the parent relationship - Assert.AreEqual(parent.id, child.Parent.id); - Assert.AreEqual(parent.key, child.Parent.key); - Assert.AreEqual(parent.UniqueId, child.Parent.UniqueId); - - //test the child relationship - Assert.IsTrue(parent.hasChildren); - Assert.AreEqual(1, parent.Children.Length); - Assert.AreEqual(child.id, parent.Children.First().id); - Assert.AreEqual(child.key, parent.Children.First().key); - Assert.AreEqual(child.UniqueId, parent.Children.First().UniqueId); - - DeleteItem(child); - DeleteItem(parent); - } - - /// - /// Deletes a parent with existing children and ensures they are all gone. - /// - [Test()] - public void Dictionary_Delete_Parent_With_Children() - { - var parent = CreateNew(); - - //create a child - var childId1 = Dictionary.DictionaryItem.addKey("Test" + Guid.NewGuid().ToString("N"), "", parent.key); - Assert.IsTrue(childId1 > 0); - var child1 = new Dictionary.DictionaryItem(childId1); - Assert.IsTrue(TypeHelper.IsTypeAssignableFrom(child1)); - - //create a child - var childId2 = Dictionary.DictionaryItem.addKey("Test" + Guid.NewGuid().ToString("N"), "", parent.key); - Assert.IsTrue(childId2 > 0); - var child2 = new Dictionary.DictionaryItem(childId2); - Assert.IsTrue(TypeHelper.IsTypeAssignableFrom(child2)); - - Assert.IsTrue(parent.hasChildren); - Assert.AreEqual(2, parent.Children.Length); - - - DeleteItem(parent); - - //make sure kids are gone - var notFound = false; - try - { - var check = new Dictionary.DictionaryItem(childId1); - } - catch (ArgumentException) - { - notFound = true; - } - Assert.IsTrue(notFound); - - notFound = false; - try - { - var check = new Dictionary.DictionaryItem(childId2); - } - catch (ArgumentException) - { - notFound = true; - } - Assert.IsTrue(notFound); - - } - - /// - /// Guid constructor test - /// - [Test()] - public void Dictionary_Contructor_Guid() - { - var d = CreateNew(); - - var same = new Dictionary.DictionaryItem(d.UniqueId); - - Assert.AreEqual(d.id, same.id); - Assert.AreEqual(d.key, same.key); - Assert.AreEqual(d.UniqueId, same.UniqueId); - - DeleteItem(d); - } - - /// - /// key constructor test - /// - [Test()] - public void Dictionary_Contructor_Key() - { - var d = CreateNew(); - - var same = new Dictionary.DictionaryItem(d.key); - - Assert.AreEqual(d.id, same.id); - Assert.AreEqual(d.key, same.key); - Assert.AreEqual(d.UniqueId, same.UniqueId); - - DeleteItem(d); - } - - /// - ///A test for ToXml - /// - [Test()] - public void Dictionary_ToXml() - { - var d = CreateNew(); - - //create a child - var childId = Dictionary.DictionaryItem.addKey("Test" + Guid.NewGuid().ToString("N"), "", d.key); - Assert.IsTrue(childId > 0); - var child = new Dictionary.DictionaryItem(childId); - Assert.IsTrue(TypeHelper.IsTypeAssignableFrom(child)); - - var xml = new XmlDocument(); - - var output = d.ToXml(xml); - - Assert.AreEqual("DictionaryItem", output.Name); - Assert.IsTrue(output.HasChildNodes); - Assert.IsNotNull(output.Attributes["Key"].Value); - Assert.AreEqual(1, output.ChildNodes.OfType().Where(x => x.Name == "DictionaryItem").Count()); - - DeleteItem(child); - DeleteItem(d); - } - - /// - ///A test to change the key of an element - /// - [Test()] - public void Dictionary_Change_Key() - { - //System.Diagnostics.Debugger.Break(); - - var d = CreateNew(); - - var oldKey = d.key; - var newKey = "NEWKEY" + Guid.NewGuid().ToString("N"); - - d.key = newKey; - d.Save(); - Assert.AreNotEqual(oldKey, d.key); - Assert.AreEqual(newKey, d.key); - - //check with sql that the key is definitely changed - var count = Application.SqlHelper.ExecuteScalar("SELECT COUNT(*) FROM cmsDictionary WHERE [key]=@key", - Application.SqlHelper.CreateParameter("@key", newKey)); - Assert.AreEqual(1, count); - - count = Application.SqlHelper.ExecuteScalar("SELECT COUNT(*) FROM cmsDictionary WHERE [key]=@key", - Application.SqlHelper.CreateParameter("@key", oldKey)); - Assert.AreEqual(0, count); - - DeleteItem(d); - } - - /// - /// Tries to create a duplicate key and ensures it's not possible. - /// - [Test()] - public void Dictionary_Attempt_Duplicate_Key() - { - var key = "Test" + Guid.NewGuid().ToString("N"); - var d1Id = Dictionary.DictionaryItem.addKey(key, ""); - Assert.IsTrue(d1Id > 0); - var d1 = new Dictionary.DictionaryItem(d1Id); - Assert.IsTrue(TypeHelper.IsTypeAssignableFrom(d1)); - - var alreadyExists = false; - try - { - var d2Id = Dictionary.DictionaryItem.addKey(key, ""); - Assert.IsTrue(d2Id > 0); - var d2 = new Dictionary.DictionaryItem(d2Id); - } - catch (ArgumentException) - { - alreadyExists = true; - } - Assert.IsTrue(alreadyExists); - - DeleteItem(d1); - } - - #region Private methods - - private Dictionary.DictionaryItem CreateNew() - { - var id = Dictionary.DictionaryItem.addKey("Test" + Guid.NewGuid().ToString("N"), ""); - Assert.IsTrue(id > 0); - - var d = new Dictionary.DictionaryItem(id); - Assert.IsTrue(TypeHelper.IsTypeAssignableFrom(d)); - - return d; - } - - private void DeleteItem(Dictionary.DictionaryItem d) - { - var id = d.id; - - d.delete(); - - var notFound = false; - try - { - var check = new Dictionary.DictionaryItem(id); - } - catch (ArgumentException) - { - notFound = true; - } - Assert.IsTrue(notFound, "The item with key " + d.key + " still exists!"); - - //check with sql that the language text is gone - var count = Application.SqlHelper.ExecuteScalar("SELECT COUNT(*) FROM cmsLanguageText WHERE uniqueId=@uniqueId", - Application.SqlHelper.CreateParameter("@uniqueId", d.UniqueId)); - Assert.AreEqual(0, count); - } - #endregion - - #region Tests to write - - - ///// - /////A test for Import - ///// - //[Test()] - //public void ImportTest() - //{ - // XmlNode xmlData = null; // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem parent = null; // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem expected = null; // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem actual; - // actual = Dictionary.DictionaryItem.Import(xmlData, parent); - // Assert.AreEqual(expected, actual); - // Assert.Inconclusive("Verify the correctness of this test method."); - //} - - ///// - /////A test for Import - ///// - //[Test()] - //public void ImportTest1() - //{ - // XmlNode xmlData = null; // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem expected = null; // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem actual; - // actual = Dictionary.DictionaryItem.Import(xmlData); - // Assert.AreEqual(expected, actual); - // Assert.Inconclusive("Verify the correctness of this test method."); - //} - - - - ///// - /////A test for Save - ///// - //[Test()] - //public void SaveTest() - //{ - // Guid id = new Guid(); // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value - // target.Save(); - // Assert.Inconclusive("A method that does not return a value cannot be verified."); - //} - - - - ///// - /////A test for Value - ///// - //[Test()] - //public void ValueTest() - //{ - // Guid id = new Guid(); // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value - // int languageId = 0; // TODO: Initialize to an appropriate value - // string expected = string.Empty; // TODO: Initialize to an appropriate value - // string actual; - // actual = target.Value(languageId); - // Assert.AreEqual(expected, actual); - // Assert.Inconclusive("Verify the correctness of this test method."); - //} - - ///// - /////A test for Value - ///// - //[Test()] - //public void ValueTest1() - //{ - // Guid id = new Guid(); // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value - // string expected = string.Empty; // TODO: Initialize to an appropriate value - // string actual; - // actual = target.Value(); - // Assert.AreEqual(expected, actual); - // Assert.Inconclusive("Verify the correctness of this test method."); - //} - - ///// - /////A test for addKey - ///// - //[Test()] - //public void addKeyTest() - //{ - // string key = string.Empty; // TODO: Initialize to an appropriate value - // string defaultValue = string.Empty; // TODO: Initialize to an appropriate value - // int expected = 0; // TODO: Initialize to an appropriate value - // int actual; - // actual = Dictionary.DictionaryItem.addKey(key, defaultValue); - // Assert.AreEqual(expected, actual); - // Assert.Inconclusive("Verify the correctness of this test method."); - //} - - ///// - /////A test for addKey - ///// - //[Test()] - //public void addKeyTest1() - //{ - // string key = string.Empty; // TODO: Initialize to an appropriate value - // string defaultValue = string.Empty; // TODO: Initialize to an appropriate value - // string parentKey = string.Empty; // TODO: Initialize to an appropriate value - // int expected = 0; // TODO: Initialize to an appropriate value - // int actual; - // actual = Dictionary.DictionaryItem.addKey(key, defaultValue, parentKey); - // Assert.AreEqual(expected, actual); - // Assert.Inconclusive("Verify the correctness of this test method."); - //} - - ///// - /////A test for delete - ///// - //[Test()] - //public void deleteTest() - //{ - // Guid id = new Guid(); // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value - // target.delete(); - // Assert.Inconclusive("A method that does not return a value cannot be verified."); - //} - - ///// - /////A test for hasKey - ///// - //[Test()] - //public void hasKeyTest() - //{ - // string key = string.Empty; // TODO: Initialize to an appropriate value - // bool expected = false; // TODO: Initialize to an appropriate value - // bool actual; - // actual = Dictionary.DictionaryItem.hasKey(key); - // Assert.AreEqual(expected, actual); - // Assert.Inconclusive("Verify the correctness of this test method."); - //} - - ///// - /////A test for setValue - ///// - //[Test()] - //public void setValueTest() - //{ - // Guid id = new Guid(); // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value - // int languageId = 0; // TODO: Initialize to an appropriate value - // string value = string.Empty; // TODO: Initialize to an appropriate value - // target.setValue(languageId, value); - // Assert.Inconclusive("A method that does not return a value cannot be verified."); - //} - - ///// - /////A test for setValue - ///// - //[Test()] - //public void setValueTest1() - //{ - // Guid id = new Guid(); // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value - // string value = string.Empty; // TODO: Initialize to an appropriate value - // target.setValue(value); - // Assert.Inconclusive("A method that does not return a value cannot be verified."); - //} - - ///// - /////A test for Children - ///// - //[Test()] - //public void ChildrenTest() - //{ - // Guid id = new Guid(); // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem[] actual; - // actual = target.Children; - // Assert.Inconclusive("Verify the correctness of this test method."); - //} - - ///// - /////A test for Parent - ///// - //[Test()] - //public void ParentTest() - //{ - // Guid id = new Guid(); // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem actual; - // actual = target.Parent; - // Assert.Inconclusive("Verify the correctness of this test method."); - //} - - ///// - /////A test for hasChildren - ///// - //[Test()] - //public void hasChildrenTest() - //{ - // Guid id = new Guid(); // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value - // bool actual; - // actual = target.hasChildren; - // Assert.Inconclusive("Verify the correctness of this test method."); - //} - - ///// - /////A test for id - ///// - //[Test()] - //public void idTest() - //{ - // Guid id = new Guid(); // TODO: Initialize to an appropriate value - // Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value - // int actual; - // actual = target.id; - // Assert.Inconclusive("Verify the correctness of this test method."); - //} - - - #endregion - - } -} diff --git a/src/Umbraco.Tests/CodeFirst/CodeFirstTests.cs b/src/Umbraco.Tests/CodeFirst/CodeFirstTests.cs index 5c388e7784..40352fb3bf 100644 --- a/src/Umbraco.Tests/CodeFirst/CodeFirstTests.cs +++ b/src/Umbraco.Tests/CodeFirst/CodeFirstTests.cs @@ -15,6 +15,7 @@ using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.CodeFirst { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class CodeFirstTests : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/CodeFirst/StronglyTypedMapperTest.cs b/src/Umbraco.Tests/CodeFirst/StronglyTypedMapperTest.cs index 3913dabe52..bb64e003bc 100644 --- a/src/Umbraco.Tests/CodeFirst/StronglyTypedMapperTest.cs +++ b/src/Umbraco.Tests/CodeFirst/StronglyTypedMapperTest.cs @@ -14,6 +14,7 @@ using Umbraco.Web; namespace Umbraco.Tests.CodeFirst { + [DatabaseTestBehavior(DatabaseBehavior.NoDatabasePerFixture)] [TestFixture] public class StronglyTypedMapperTest : PublishedContentTestBase { @@ -98,11 +99,6 @@ namespace Umbraco.Tests.CodeFirst base.TearDown(); } - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NoDatabasePerFixture; } - } - protected override string GetXmlContent(int templateId) { return @" diff --git a/src/Umbraco.Tests/GlobalSettingsTests.cs b/src/Umbraco.Tests/GlobalSettingsTests.cs index 0c86a20a77..8ba0492eda 100644 --- a/src/Umbraco.Tests/GlobalSettingsTests.cs +++ b/src/Umbraco.Tests/GlobalSettingsTests.cs @@ -11,10 +11,6 @@ namespace Umbraco.Tests [TestFixture] public class GlobalSettingsTests : BaseWebTest { - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NoDatabasePerFixture; } - } public override void Initialize() { diff --git a/src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs b/src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs deleted file mode 100644 index 26e93961ac..0000000000 --- a/src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Linq; -using NUnit.Framework; -using Umbraco.Core.Models.Rdbms; -using Umbraco.Tests.TestHelpers; -using Umbraco.Tests.TestHelpers.Entities; -using umbraco.BusinessLogic; -using umbraco.cms.businesslogic.datatype; -using umbraco.cms.businesslogic.media; -using Umbraco.Core; - -namespace Umbraco.Tests.LegacyApi -{ - [TestFixture, Ignore] - public class MediaTypeTests : BaseDatabaseFactoryTest - { - [SetUp] - public override void Initialize() - { - base.Initialize(); - - CreateTestData(); - } - - [Test] - public void Can_Verify_AllowedChildContentTypes_On_MediaType() - { - // Arrange - var folder = MediaType.GetByAlias(Constants.Conventions.MediaTypes.Folder); - var folderStructure = folder.AllowedChildContentTypeIDs.ToList(); - folderStructure.Add(NodeDto.NodeIdSeed); - - // Act - folder.AllowedChildContentTypeIDs = folderStructure.ToArray(); - folder.Save(); - - // Assert - var updated = MediaType.GetByAlias(Constants.Conventions.MediaTypes.Folder); - - Assert.That(updated.AllowedChildContentTypeIDs.Any(), Is.True); - Assert.That(updated.AllowedChildContentTypeIDs.Any(x => x == NodeDto.NodeIdSeed), Is.True); - } - - [Test] - public void Can_Set_Tab_On_PropertyType() - { - var UPLOAD_DATATYPE_ID = -90; - var CROP_DATATYPE_ID = 1043; - var LABEL_DATATYPE_ID = -92; - var mediaTypeName = "ImageWide"; - - MediaType mediaType = MediaType.MakeNew(new User(0), mediaTypeName); - - int imageTab = mediaType.AddVirtualTab("Image"); - int cropTab = mediaType.AddVirtualTab("Crop"); - - mediaType.AddPropertyType(new DataTypeDefinition(UPLOAD_DATATYPE_ID), Constants.Conventions.Media.File, "Upload image"); - mediaType.AddPropertyType(new DataTypeDefinition(LABEL_DATATYPE_ID), Constants.Conventions.Media.Width, "Width"); - mediaType.AddPropertyType(new DataTypeDefinition(LABEL_DATATYPE_ID), Constants.Conventions.Media.Height, "Height"); - mediaType.AddPropertyType(new DataTypeDefinition(LABEL_DATATYPE_ID), Constants.Conventions.Media.Bytes, "Size"); - mediaType.AddPropertyType(new DataTypeDefinition(LABEL_DATATYPE_ID), Constants.Conventions.Media.Extension, "Type"); - mediaType.AddPropertyType(new DataTypeDefinition(CROP_DATATYPE_ID), "wideImage", "Wide image"); - - mediaType.SetTabOnPropertyType(mediaType.getPropertyType(Constants.Conventions.Media.File), imageTab); - mediaType.SetTabOnPropertyType(mediaType.getPropertyType(Constants.Conventions.Media.Width), imageTab); - mediaType.SetTabOnPropertyType(mediaType.getPropertyType(Constants.Conventions.Media.Height), imageTab); - mediaType.SetTabOnPropertyType(mediaType.getPropertyType(Constants.Conventions.Media.Bytes), imageTab); - mediaType.SetTabOnPropertyType(mediaType.getPropertyType(Constants.Conventions.Media.Extension), imageTab); - mediaType.SetTabOnPropertyType(mediaType.getPropertyType("wideImage"), cropTab); - - mediaType.Text = mediaTypeName; - mediaType.IconUrl = "mediaPhoto.gif"; - mediaType.Save(); - - Assert.That(mediaType.getVirtualTabs.Count(), Is.EqualTo(2)); - Assert.That(mediaType.getVirtualTabs.Any(x => x.Caption.Equals("Image")), Is.True); - Assert.That(mediaType.getVirtualTabs.Any(x => x.Caption.Equals("Crop")), Is.True); - - var updated = new MediaType(mediaType.Id); - Assert.That(updated.getVirtualTabs.Count(), Is.EqualTo(2)); - Assert.That(updated.getVirtualTabs.Any(x => x.Caption.Equals("Image")), Is.True); - Assert.That(updated.getVirtualTabs.Any(x => x.Caption.Equals("Crop")), Is.True); - Assert.That(updated.ContentTypeItem.PropertyGroups.Count(), Is.EqualTo(2)); - Assert.That(updated.ContentTypeItem.PropertyTypes.Count(), Is.EqualTo(6)); - } - - public void CreateTestData() - { - //Create and Save ContentType "video" -> NodeDto.NodeIdSeed - var videoMediaType = MockedContentTypes.CreateVideoMediaType(); - ServiceContext.ContentTypeService.Save(videoMediaType); - } - - - [TearDown] - public override void TearDown() - { - base.TearDown(); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Tests/LibraryTests.cs b/src/Umbraco.Tests/LibraryTests.cs index 4469a4f3ad..db5a2fd593 100644 --- a/src/Umbraco.Tests/LibraryTests.cs +++ b/src/Umbraco.Tests/LibraryTests.cs @@ -56,10 +56,6 @@ namespace Umbraco.Tests UmbracoContext.Current = null; } - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NoDatabasePerFixture; } - } [Test] public void Get_Item_User_Property() diff --git a/src/Umbraco.Tests/Membership/DynamicMemberContentTests.cs b/src/Umbraco.Tests/Membership/DynamicMemberContentTests.cs index 023e330871..66f7d01e00 100644 --- a/src/Umbraco.Tests/Membership/DynamicMemberContentTests.cs +++ b/src/Umbraco.Tests/Membership/DynamicMemberContentTests.cs @@ -17,15 +17,11 @@ using Umbraco.Web.PublishedCache; namespace Umbraco.Tests.Membership { + [DatabaseTestBehavior(DatabaseBehavior.NoDatabasePerFixture)] [TestFixture] public class DynamicMemberContentTests : PublishedContentTestBase { - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NoDatabasePerFixture; } - } - public override void Initialize() { // required so we can access property.Value diff --git a/src/Umbraco.Tests/Models/ContentXmlTest.cs b/src/Umbraco.Tests/Models/ContentXmlTest.cs index 7910860ed4..11b925e9fd 100644 --- a/src/Umbraco.Tests/Models/ContentXmlTest.cs +++ b/src/Umbraco.Tests/Models/ContentXmlTest.cs @@ -9,6 +9,7 @@ using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.Models { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class ContentXmlTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Models/MediaXmlTest.cs b/src/Umbraco.Tests/Models/MediaXmlTest.cs index ecfbc3ce61..cc82f7ce88 100644 --- a/src/Umbraco.Tests/Models/MediaXmlTest.cs +++ b/src/Umbraco.Tests/Models/MediaXmlTest.cs @@ -12,6 +12,7 @@ using umbraco.interfaces; namespace Umbraco.Tests.Models { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class MediaXmlTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Auditing/AuditTests.cs b/src/Umbraco.Tests/Persistence/Auditing/AuditTests.cs index 68e7bcb003..82c36b5cfa 100644 --- a/src/Umbraco.Tests/Persistence/Auditing/AuditTests.cs +++ b/src/Umbraco.Tests/Persistence/Auditing/AuditTests.cs @@ -6,6 +6,7 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Persistence.Auditing { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class AuditTests : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/DatabaseContextTests.cs b/src/Umbraco.Tests/Persistence/DatabaseContextTests.cs index 5bf2264c5c..938ea2f809 100644 --- a/src/Umbraco.Tests/Persistence/DatabaseContextTests.cs +++ b/src/Umbraco.Tests/Persistence/DatabaseContextTests.cs @@ -10,6 +10,7 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Persistence { + [TestFixture] public class DatabaseContextTests { @@ -75,6 +76,9 @@ namespace Umbraco.Tests.Persistence var engine = new SqlCeEngine(settings.ConnectionString.Replace("UmbracoPetaPocoTests", "DatabaseContextTests")); engine.CreateDatabase(); + //re-map the dbcontext to the new conn string + _dbContext = new DatabaseContext(new DefaultDatabaseFactory(engine.LocalConnectionString, "System.Data.SqlServerCe.4.0")); + SqlSyntaxContext.SqlSyntaxProvider = SqlCeSyntax.Provider; //Create the umbraco database diff --git a/src/Umbraco.Tests/Persistence/PetaPocoExtensionsTest.cs b/src/Umbraco.Tests/Persistence/PetaPocoExtensionsTest.cs index 3a76e29139..b0b7247edb 100644 --- a/src/Umbraco.Tests/Persistence/PetaPocoExtensionsTest.cs +++ b/src/Umbraco.Tests/Persistence/PetaPocoExtensionsTest.cs @@ -9,6 +9,7 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Persistence { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class PetaPocoExtensionsTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs index 1433920eba..c67a5e2784 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs @@ -18,6 +18,7 @@ using umbraco.interfaces; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class ContentRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs index 21ebb32542..65cba772dc 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs @@ -15,6 +15,7 @@ using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class ContentTypeRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs index 5a3470d457..7d828dfc48 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs @@ -14,6 +14,7 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class DataTypeDefinitionRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/DictionaryRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/DictionaryRepositoryTest.cs index e8e25068db..6619478aaf 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/DictionaryRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/DictionaryRepositoryTest.cs @@ -11,6 +11,7 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class DictionaryRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/LanguageRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/LanguageRepositoryTest.cs index c1ac5fa6a9..037848a911 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/LanguageRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/LanguageRepositoryTest.cs @@ -10,6 +10,7 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class LanguageRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs index 884ba5b383..ba98ae0cc7 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs @@ -17,6 +17,7 @@ using umbraco.interfaces; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class MediaRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs index d10884cb39..8837a02cb1 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs @@ -13,6 +13,7 @@ using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class MediaTypeRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs index ecaaa4bab9..93226eec4c 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs @@ -14,6 +14,7 @@ using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class MemberRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/MemberTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MemberTypeRepositoryTest.cs index 63e9956f11..5f00e5b4b7 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/MemberTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/MemberTypeRepositoryTest.cs @@ -11,6 +11,7 @@ using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class MemberTypeRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/NotificationsRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/NotificationsRepositoryTest.cs index a026d2656d..432b102dcf 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/NotificationsRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/NotificationsRepositoryTest.cs @@ -13,6 +13,7 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class NotificationsRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs index 6ec5d29cc8..3b6edea115 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs @@ -16,6 +16,7 @@ using umbraco.interfaces; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class RelationRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/RelationTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/RelationTypeRepositoryTest.cs index ce0fada6f6..1c92f11802 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/RelationTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/RelationTypeRepositoryTest.cs @@ -12,6 +12,7 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class RelationTypeRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs index 19b4a7f7d9..6188c351a1 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs @@ -11,6 +11,7 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class ServerRegistrationRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs index d91bc0e309..09b140940a 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs @@ -10,6 +10,7 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class StylesheetRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs index aa5d4e27d6..db7d553a58 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs @@ -13,6 +13,7 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class TemplateRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs index d460dbed36..40ea5177cf 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs @@ -14,6 +14,7 @@ using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class UserRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/Repositories/UserTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/UserTypeRepositoryTest.cs index 67ded331e3..26d53492d0 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/UserTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/UserTypeRepositoryTest.cs @@ -11,6 +11,7 @@ using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.Persistence.Repositories { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class UserTypeRepositoryTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Persistence/SchemaValidationTest.cs b/src/Umbraco.Tests/Persistence/SchemaValidationTest.cs index f4aaa7c064..14581378f9 100644 --- a/src/Umbraco.Tests/Persistence/SchemaValidationTest.cs +++ b/src/Umbraco.Tests/Persistence/SchemaValidationTest.cs @@ -5,6 +5,7 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Persistence { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class SchemaValidationTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/PublishedCache/PublishedContentCacheTests.cs b/src/Umbraco.Tests/PublishedCache/PublishedContentCacheTests.cs index f8658734cc..e915267f77 100644 --- a/src/Umbraco.Tests/PublishedCache/PublishedContentCacheTests.cs +++ b/src/Umbraco.Tests/PublishedCache/PublishedContentCacheTests.cs @@ -17,6 +17,7 @@ using umbraco.BusinessLogic; namespace Umbraco.Tests.PublishedCache { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class PublishContentCacheTests : BaseWebTest { diff --git a/src/Umbraco.Tests/PublishedCache/PublishedMediaCacheTests.cs b/src/Umbraco.Tests/PublishedCache/PublishedMediaCacheTests.cs index e8c03850a8..53a8b5b658 100644 --- a/src/Umbraco.Tests/PublishedCache/PublishedMediaCacheTests.cs +++ b/src/Umbraco.Tests/PublishedCache/PublishedMediaCacheTests.cs @@ -16,6 +16,7 @@ using umbraco.BusinessLogic; namespace Umbraco.Tests.PublishedCache { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class PublishMediaCacheTests : BaseWebTest { diff --git a/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs b/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs index 4f497a1613..5e5b4c6ed1 100644 --- a/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs +++ b/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs @@ -15,11 +15,6 @@ namespace Umbraco.Tests.PublishedContent [TestFixture] public abstract class DynamicDocumentTestsBase : PublishedContentTestBase { - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NoDatabasePerFixture; } - } - public override void Initialize() { // required so we can access property.Value diff --git a/src/Umbraco.Tests/PublishedContent/DynamicNodeTests.cs b/src/Umbraco.Tests/PublishedContent/DynamicNodeTests.cs index 903c4ba3d2..ec2fdcbee5 100644 --- a/src/Umbraco.Tests/PublishedContent/DynamicNodeTests.cs +++ b/src/Umbraco.Tests/PublishedContent/DynamicNodeTests.cs @@ -14,16 +14,10 @@ using System.Linq; namespace Umbraco.Tests.PublishedContent { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class DynamicNodeTests : DynamicDocumentTestsBase { - /// - /// We only need a new schema per fixture... speeds up testing - /// - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NewSchemaPerFixture; } - } public override void Initialize() { diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentExtensionTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentExtensionTests.cs index 2134bec0ce..d43c3a2ca0 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentExtensionTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentExtensionTests.cs @@ -9,18 +9,14 @@ using Umbraco.Web; namespace Umbraco.Tests.PublishedContent { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class PublishedContentExtensionTests : PublishedContentTestBase { private UmbracoContext ctx; private string xmlContent = ""; private bool createContentTypes = true; - - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NewSchemaPerFixture; } - } - + protected override string GetXmlContent(int templateId) { return xmlContent; diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentRequestEngineTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentRequestEngineTests.cs index 5bfc94fd05..25fa7df5f7 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentRequestEngineTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentRequestEngineTests.cs @@ -13,12 +13,6 @@ namespace Umbraco.Tests.PublishedContent [TestFixture] public class PublishedContentRequestEngineTests : BaseRoutingTest { - - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NoDatabasePerFixture; } - } - [Test] public void Ctor_Throws_On_Null_PCR() { diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs index 610d135870..ed6603fe6d 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs @@ -18,11 +18,6 @@ namespace Umbraco.Tests.PublishedContent [TestFixture] public class PublishedContentTests : PublishedContentTestBase { - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NoDatabasePerFixture; } - } - private PluginManager _pluginManager; public override void Initialize() diff --git a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs index ab7a015175..2af87d37d2 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs @@ -32,6 +32,7 @@ namespace Umbraco.Tests.PublishedContent /// /// Tests the typed extension methods on IPublishedContent using the DefaultPublishedMediaStore /// + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture, RequiresSTA] public class PublishedMediaTests : PublishedContentTestBase { diff --git a/src/Umbraco.Tests/Publishing/PublishingStrategyTests.cs b/src/Umbraco.Tests/Publishing/PublishingStrategyTests.cs index fdac3513ab..b844900d9c 100644 --- a/src/Umbraco.Tests/Publishing/PublishingStrategyTests.cs +++ b/src/Umbraco.Tests/Publishing/PublishingStrategyTests.cs @@ -18,6 +18,7 @@ using System.Linq; namespace Umbraco.Tests.Publishing { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture] public class PublishingStrategyTests : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Routing/ContentFinderByAliasTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByAliasTests.cs index fb54207578..60fee894d3 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByAliasTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByAliasTests.cs @@ -8,11 +8,6 @@ namespace Umbraco.Tests.Routing [TestFixture] public class ContentFinderByAliasTests : BaseRoutingTest { - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NoDatabasePerFixture; } - } - [TestCase("/this/is/my/alias", 1001)] [TestCase("/anotheralias", 1001)] [TestCase("/page2/alias", 10011)] diff --git a/src/Umbraco.Tests/Routing/ContentFinderByAliasWithDomainsTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByAliasWithDomainsTests.cs index a45ac7a12b..b83f0bfd2b 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByAliasWithDomainsTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByAliasWithDomainsTests.cs @@ -7,6 +7,7 @@ using umbraco.cms.businesslogic.web; namespace Umbraco.Tests.Routing { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class ContentFinderByAliasWithDomainsTests : ContentFinderByAliasTests { @@ -20,11 +21,6 @@ namespace Umbraco.Tests.Routing InitializeLanguagesAndDomains(); } - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NewSchemaPerFixture; } - } - void InitializeLanguagesAndDomains() { var domains = Domain.GetDomains(); diff --git a/src/Umbraco.Tests/Routing/ContentFinderByIdTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByIdTests.cs index dcbf1dcb9b..6623ac23b9 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByIdTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByIdTests.cs @@ -9,13 +9,6 @@ namespace Umbraco.Tests.Routing [TestFixture] public class ContentFinderByIdTests : BaseRoutingTest { - /// - /// We don't need a db for this test, will run faster without one - /// - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NoDatabasePerFixture; } - } [TestCase("/1046", 1046)] [TestCase("/1046.aspx", 1046)] diff --git a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlAndTemplateTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlAndTemplateTests.cs index 7c4618f0b4..8308241607 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlAndTemplateTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlAndTemplateTests.cs @@ -6,6 +6,7 @@ using Umbraco.Core.Models; namespace Umbraco.Tests.Routing { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class ContentFinderByNiceUrlAndTemplateTests : BaseRoutingTest { diff --git a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlTests.cs index 6be14fce80..8002acd0ac 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlTests.cs @@ -12,13 +12,7 @@ namespace Umbraco.Tests.Routing [TestFixture] public class ContentFinderByNiceUrlTests : BaseRoutingTest { - /// - /// We don't need a db for this test, will run faster without one - /// - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NoDatabasePerFixture; } - } + [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/ContentFinderByNiceUrlWithDomainsTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlWithDomainsTests.cs index 2764787bcd..15912a8c5d 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlWithDomainsTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlWithDomainsTests.cs @@ -11,6 +11,7 @@ using System.Configuration; namespace Umbraco.Tests.Routing { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class ContentFinderByNiceUrlWithDomainsTests : BaseRoutingTest { diff --git a/src/Umbraco.Tests/Routing/ContentFinderByPageIdQueryTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByPageIdQueryTests.cs index c21360fa7c..d887bafe66 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByPageIdQueryTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByPageIdQueryTests.cs @@ -10,14 +10,6 @@ namespace Umbraco.Tests.Routing [TestFixture] public class ContentFinderByPageIdQueryTests : BaseRoutingTest { - /// - /// We don't need a db for this test, will run faster without one - /// - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NoDatabasePerFixture; } - } - [TestCase("/?umbPageId=1046", 1046)] [TestCase("/?UMBPAGEID=1046", 1046)] [TestCase("/default.aspx?umbPageId=1046", 1046)] //TODO: Should this match?? diff --git a/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs b/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs index 23a9141e9c..27b00cf676 100644 --- a/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs +++ b/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs @@ -10,6 +10,7 @@ using umbraco.cms.businesslogic.language; namespace Umbraco.Tests.Routing { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] class DomainsAndCulturesTests : BaseRoutingTest { diff --git a/src/Umbraco.Tests/Routing/NiceUrlProviderTests.cs b/src/Umbraco.Tests/Routing/NiceUrlProviderTests.cs index 55d2c92df8..bf1d862463 100644 --- a/src/Umbraco.Tests/Routing/NiceUrlProviderTests.cs +++ b/src/Umbraco.Tests/Routing/NiceUrlProviderTests.cs @@ -10,6 +10,7 @@ using Umbraco.Web.Routing; namespace Umbraco.Tests.Routing { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class NiceUrlProviderTests : BaseRoutingTest { diff --git a/src/Umbraco.Tests/Routing/NiceUrlsProviderWithDomainsTests.cs b/src/Umbraco.Tests/Routing/NiceUrlsProviderWithDomainsTests.cs index b01fd43c55..c16bd28fbf 100644 --- a/src/Umbraco.Tests/Routing/NiceUrlsProviderWithDomainsTests.cs +++ b/src/Umbraco.Tests/Routing/NiceUrlsProviderWithDomainsTests.cs @@ -12,6 +12,7 @@ using umbraco.cms.businesslogic.language; namespace Umbraco.Tests.Routing { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class NiceUrlsProviderWithDomainsTests : BaseRoutingTest { @@ -23,11 +24,6 @@ namespace Umbraco.Tests.Routing TestHelper.DropForeignKeys("umbracoDomains"); } - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NewSchemaPerFixture; } - } - protected override void FreezeResolution() { SiteDomainHelperResolver.Current = new SiteDomainHelperResolver(new SiteDomainHelper()); diff --git a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs index 794c9b0401..a1f63aa452 100644 --- a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs +++ b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs @@ -15,13 +15,10 @@ using Umbraco.Core.Strings; namespace Umbraco.Tests.Routing { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class RenderRouteHandlerTests : BaseRoutingTest { - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NewSchemaPerFixture; } - } public override void Initialize() { diff --git a/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs b/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs index 3dcb84eca3..6bb30f489b 100644 --- a/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs +++ b/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs @@ -12,6 +12,7 @@ using System.Configuration; namespace Umbraco.Tests.Routing { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class UrlsWithNestedDomains : BaseRoutingTest { diff --git a/src/Umbraco.Tests/Routing/uQueryGetNodeIdByUrlTests.cs b/src/Umbraco.Tests/Routing/uQueryGetNodeIdByUrlTests.cs index 53d5301246..9e8dd33fc4 100644 --- a/src/Umbraco.Tests/Routing/uQueryGetNodeIdByUrlTests.cs +++ b/src/Umbraco.Tests/Routing/uQueryGetNodeIdByUrlTests.cs @@ -14,6 +14,7 @@ using umbraco.cms.businesslogic.template; namespace Umbraco.Tests.Routing { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class uQueryGetNodeIdByUrlTests : BaseRoutingTest { diff --git a/src/Umbraco.Tests/Services/ContentServiceTests.cs b/src/Umbraco.Tests/Services/ContentServiceTests.cs index b5cd6842d0..9a71d78189 100644 --- a/src/Umbraco.Tests/Services/ContentServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentServiceTests.cs @@ -10,6 +10,7 @@ using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Core.Services; +using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.Services @@ -19,6 +20,7 @@ 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 ContentServiceTests : BaseServiceTest { diff --git a/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs b/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs index 90bc77a0b3..a6d27ad7ba 100644 --- a/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs @@ -5,10 +5,12 @@ using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; +using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.Services { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture, RequiresSTA] public class ContentTypeServiceTests : BaseServiceTest { diff --git a/src/Umbraco.Tests/Services/DataTypeServiceTests.cs b/src/Umbraco.Tests/Services/DataTypeServiceTests.cs index 9ff9012062..8238fa4c7b 100644 --- a/src/Umbraco.Tests/Services/DataTypeServiceTests.cs +++ b/src/Umbraco.Tests/Services/DataTypeServiceTests.cs @@ -4,12 +4,14 @@ using System.Linq; using NUnit.Framework; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; +using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Services { /// /// Tests covering the DataTypeService /// + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture, RequiresSTA] public class DataTypeServiceTests : BaseServiceTest { diff --git a/src/Umbraco.Tests/Services/EntityServiceTests.cs b/src/Umbraco.Tests/Services/EntityServiceTests.cs index 00384b1233..0c92545334 100644 --- a/src/Umbraco.Tests/Services/EntityServiceTests.cs +++ b/src/Umbraco.Tests/Services/EntityServiceTests.cs @@ -11,6 +11,7 @@ namespace Umbraco.Tests.Services /// /// Tests covering the EntityService /// + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture, RequiresSTA] public class EntityServiceTests : BaseServiceTest { @@ -25,12 +26,7 @@ namespace Umbraco.Tests.Services { base.TearDown(); } - - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NewSchemaPerFixture; } - } - + [Test] public void EntityService_Can_Find_All_Content_By_UmbracoObjectTypes() { diff --git a/src/Umbraco.Tests/Services/Importing/PackageImportTests.cs b/src/Umbraco.Tests/Services/Importing/PackageImportTests.cs index 5a412966f3..e920a4e34f 100644 --- a/src/Umbraco.Tests/Services/Importing/PackageImportTests.cs +++ b/src/Umbraco.Tests/Services/Importing/PackageImportTests.cs @@ -4,9 +4,11 @@ using System.Xml.Linq; using NUnit.Framework; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; +using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Services.Importing { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)] [TestFixture, RequiresSTA] public class PackageImportTests : BaseServiceTest { diff --git a/src/Umbraco.Tests/Services/LocalizationServiceTests.cs b/src/Umbraco.Tests/Services/LocalizationServiceTests.cs index fa5c6f3253..6b22da6800 100644 --- a/src/Umbraco.Tests/Services/LocalizationServiceTests.cs +++ b/src/Umbraco.Tests/Services/LocalizationServiceTests.cs @@ -1,4 +1,5 @@ using NUnit.Framework; +using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Services { @@ -7,6 +8,7 @@ namespace Umbraco.Tests.Services /// This is more of an integration test as it involves multiple layers /// as well as configuration. /// + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture, RequiresSTA] public class LocalizationServiceTests : BaseServiceTest { diff --git a/src/Umbraco.Tests/Services/MediaServiceTests.cs b/src/Umbraco.Tests/Services/MediaServiceTests.cs index fa9e530f3a..d6a3fe82c9 100644 --- a/src/Umbraco.Tests/Services/MediaServiceTests.cs +++ b/src/Umbraco.Tests/Services/MediaServiceTests.cs @@ -4,10 +4,12 @@ using System.Linq; using System.Text; using NUnit.Framework; using Umbraco.Core.Models; +using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.Services { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture, RequiresSTA] public class MediaServiceTests : BaseServiceTest { diff --git a/src/Umbraco.Tests/Services/MemberServiceTests.cs b/src/Umbraco.Tests/Services/MemberServiceTests.cs index 1e9f75b80f..fdfd003b9a 100644 --- a/src/Umbraco.Tests/Services/MemberServiceTests.cs +++ b/src/Umbraco.Tests/Services/MemberServiceTests.cs @@ -8,10 +8,12 @@ using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Services; +using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.Services { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture, RequiresSTA] public class MemberServiceTests : BaseServiceTest { diff --git a/src/Umbraco.Tests/Services/MemberTypeServiceTests.cs b/src/Umbraco.Tests/Services/MemberTypeServiceTests.cs index bf93abe8e7..e4b891ac2e 100644 --- a/src/Umbraco.Tests/Services/MemberTypeServiceTests.cs +++ b/src/Umbraco.Tests/Services/MemberTypeServiceTests.cs @@ -6,10 +6,12 @@ using umbraco.cms.presentation.create.controls; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; +using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.Services { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture, RequiresSTA] public class MemberTypeServiceTests : BaseServiceTest { diff --git a/src/Umbraco.Tests/Services/PackagingServiceTests.cs b/src/Umbraco.Tests/Services/PackagingServiceTests.cs index 22c41ee669..d11c2ad157 100644 --- a/src/Umbraco.Tests/Services/PackagingServiceTests.cs +++ b/src/Umbraco.Tests/Services/PackagingServiceTests.cs @@ -4,9 +4,11 @@ using System.Xml.Linq; using NUnit.Framework; using Umbraco.Core.Models; using Umbraco.Tests.Services.Importing; +using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Services { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class PackagingServiceTests : BaseServiceTest { diff --git a/src/Umbraco.Tests/Services/PerformanceTests.cs b/src/Umbraco.Tests/Services/PerformanceTests.cs index 947a5d4acc..2655dc8915 100644 --- a/src/Umbraco.Tests/Services/PerformanceTests.cs +++ b/src/Umbraco.Tests/Services/PerformanceTests.cs @@ -26,6 +26,7 @@ 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] [NUnit.Framework.Ignore("These should not be run by the server, only directly as they are only benchmark tests")] public class PerformanceTests : BaseDatabaseFactoryTest @@ -46,13 +47,6 @@ namespace Umbraco.Tests.Services return "System.Data.SqlClient"; } - /// - /// new schema per test - /// - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NewSchemaPerTest; } - } /// /// don't create anything, we're testing against our own server diff --git a/src/Umbraco.Tests/Services/RelationServiceTests.cs b/src/Umbraco.Tests/Services/RelationServiceTests.cs index e2b9f57287..d98ff2b128 100644 --- a/src/Umbraco.Tests/Services/RelationServiceTests.cs +++ b/src/Umbraco.Tests/Services/RelationServiceTests.cs @@ -2,9 +2,11 @@ using System; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Models; +using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Services { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture, RequiresSTA] public class RelationServiceTests : BaseServiceTest { diff --git a/src/Umbraco.Tests/Services/ThreadSafetyServiceTest.cs b/src/Umbraco.Tests/Services/ThreadSafetyServiceTest.cs index eaa3c9c65c..931dae13f4 100644 --- a/src/Umbraco.Tests/Services/ThreadSafetyServiceTest.cs +++ b/src/Umbraco.Tests/Services/ThreadSafetyServiceTest.cs @@ -18,6 +18,7 @@ using umbraco.interfaces; namespace Umbraco.Tests.Services { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture, RequiresSTA] public class ThreadSafetyServiceTest : BaseDatabaseFactoryTest { diff --git a/src/Umbraco.Tests/Services/UserServiceTests.cs b/src/Umbraco.Tests/Services/UserServiceTests.cs index 22d3a9d516..2bdebb8a51 100644 --- a/src/Umbraco.Tests/Services/UserServiceTests.cs +++ b/src/Umbraco.Tests/Services/UserServiceTests.cs @@ -15,6 +15,7 @@ namespace Umbraco.Tests.Services /// /// Tests covering the UserService /// + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture, RequiresSTA] public class UserServiceTests : BaseServiceTest { diff --git a/src/Umbraco.Tests/Surface/PluginControllerAreaTests.cs b/src/Umbraco.Tests/Surface/PluginControllerAreaTests.cs index 20cac092a0..2ed7bf9876 100644 --- a/src/Umbraco.Tests/Surface/PluginControllerAreaTests.cs +++ b/src/Umbraco.Tests/Surface/PluginControllerAreaTests.cs @@ -12,11 +12,7 @@ namespace Umbraco.Tests.Surface [TestFixture] public class PluginControllerAreaTests : BaseWebTest { - protected override DatabaseBehavior DatabaseTestBehavior - { - get { return DatabaseBehavior.NoDatabasePerFixture; } - } - + [Test] public void Ensure_Same_Area1() { diff --git a/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs b/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs index c030ad3c04..582e5ad94f 100644 --- a/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs +++ b/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs @@ -76,7 +76,7 @@ namespace Umbraco.Tests.TestHelpers base.Initialize(); - using (DisposableTimer.TraceDuration("init")) + using (DisposableTimer.TraceDuration("base db init")) { //TODO: Somehow make this faster - takes 5s + @@ -97,9 +97,13 @@ namespace Umbraco.Tests.TestHelpers /// /// The database behavior to use for the test/fixture /// - protected virtual DatabaseBehavior DatabaseTestBehavior + protected DatabaseBehavior DatabaseTestBehavior { - get { return DatabaseBehavior.NewSchemaPerTest; } + get + { + var att = this.GetType().GetCustomAttribute(false); + return att != null ? att.Behavior : DatabaseBehavior.NoDatabasePerFixture; + } } protected virtual string GetDbProviderName() @@ -144,29 +148,27 @@ namespace Umbraco.Tests.TestHelpers || DatabaseTestBehavior == DatabaseBehavior.NewDbFileAndSchemaPerTest || (_isFirstTestInFixture && DatabaseTestBehavior == DatabaseBehavior.NewDbFileAndSchemaPerFixture)) { - - RemoveDatabaseFile(ex => + + using (DisposableTimer.TraceDuration("Remove database file")) + { + RemoveDatabaseFile(ex => { //if this doesn't work we have to make sure everything is reset! otherwise // well run into issues because we've already set some things up TearDown(); throw ex; }); + } //Create the Sql CE database - var engine = new SqlCeEngine(settings.ConnectionString); - engine.CreateDatabase(); + using (DisposableTimer.TraceDuration("Create database file")) + { + var engine = new SqlCeEngine(settings.ConnectionString); + engine.CreateDatabase(); + } + } - //clear the database if - // - NewSchemaPerTest - // - _isFirstTestInFixture + DbInitBehavior.NewSchemaPerFixture - - else if (DatabaseTestBehavior == DatabaseBehavior.NewSchemaPerTest - || (_isFirstTestInFixture && DatabaseTestBehavior == DatabaseBehavior.NewSchemaPerFixture)) - { - DatabaseContext.Database.UninstallDatabaseSchema(); - } } /// @@ -205,14 +207,12 @@ namespace Umbraco.Tests.TestHelpers //create the schema and load default data if: // - is the first test in the session - // - NewSchemaPerTest // - NewDbFileAndSchemaPerTest - // - _isFirstTestInFixture + DbInitBehavior.NewSchemaPerFixture // - _isFirstTestInFixture + DbInitBehavior.NewDbFileAndSchemaPerFixture if (_isFirstRunInTestSession - || DatabaseTestBehavior == DatabaseBehavior.NewSchemaPerTest - || (_isFirstTestInFixture && DatabaseTestBehavior == DatabaseBehavior.NewSchemaPerFixture)) + || DatabaseTestBehavior == DatabaseBehavior.NewDbFileAndSchemaPerTest + || (_isFirstTestInFixture && DatabaseTestBehavior == DatabaseBehavior.NewDbFileAndSchemaPerFixture)) { //Create the umbraco database and its base data DatabaseContext.Database.CreateDatabaseSchema(false); @@ -222,10 +222,7 @@ namespace Umbraco.Tests.TestHelpers [TestFixtureTearDown] public void FixtureTearDown() { - if (DatabaseTestBehavior == DatabaseBehavior.NewDbFileAndSchemaPerFixture) - { - RemoveDatabaseFile(); - } + RemoveDatabaseFile(); } [TearDown] @@ -236,11 +233,7 @@ namespace Umbraco.Tests.TestHelpers if (DatabaseTestBehavior == DatabaseBehavior.NewDbFileAndSchemaPerTest) { RemoveDatabaseFile(); - } - else if (DatabaseTestBehavior == DatabaseBehavior.NewSchemaPerTest) - { - DatabaseContext.Database.UninstallDatabaseSchema(); - } + } AppDomain.CurrentDomain.SetData("DataDirectory", null); diff --git a/src/Umbraco.Tests/TestHelpers/DatabaseBehavior.cs b/src/Umbraco.Tests/TestHelpers/DatabaseBehavior.cs index 40c5190047..643d324370 100644 --- a/src/Umbraco.Tests/TestHelpers/DatabaseBehavior.cs +++ b/src/Umbraco.Tests/TestHelpers/DatabaseBehavior.cs @@ -14,20 +14,11 @@ /// For each test a new database file and schema will be created /// NewDbFileAndSchemaPerTest, - - /// - /// For each test a new schema will be created on the existing database file - /// - NewSchemaPerTest, - + /// /// Creates a new database file and schema for the whole fixture, each test will use the pre-existing one /// - NewDbFileAndSchemaPerFixture, - - /// - /// Creates a new schema based on the existing database file for the whole fixture, each test will use the pre-existing one - /// - NewSchemaPerFixture, + NewDbFileAndSchemaPerFixture + } } \ No newline at end of file diff --git a/src/Umbraco.Tests/TestHelpers/DatabaseTestBehaviorAttribute.cs b/src/Umbraco.Tests/TestHelpers/DatabaseTestBehaviorAttribute.cs new file mode 100644 index 0000000000..a6bee4515c --- /dev/null +++ b/src/Umbraco.Tests/TestHelpers/DatabaseTestBehaviorAttribute.cs @@ -0,0 +1,15 @@ +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/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index f654b441a7..ce971d35a0 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -167,7 +167,6 @@ - @@ -246,7 +245,6 @@ - @@ -334,6 +332,7 @@ + diff --git a/src/Umbraco.Tests/UmbracoExamine/ContentServiceTest.cs b/src/Umbraco.Tests/UmbracoExamine/ContentServiceTest.cs index fd408bcc88..b41ad94573 100644 --- a/src/Umbraco.Tests/UmbracoExamine/ContentServiceTest.cs +++ b/src/Umbraco.Tests/UmbracoExamine/ContentServiceTest.cs @@ -7,6 +7,7 @@ using UmbracoExamine.DataServices; namespace Umbraco.Tests.UmbracoExamine { + [DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)] [TestFixture] public class ContentServiceTest : BaseDatabaseFactoryTest {