From c7aad452eeecda0b753d2d22a43e8503d43f3631 Mon Sep 17 00:00:00 2001 From: Mole Date: Tue, 6 Oct 2020 14:16:29 +0200 Subject: [PATCH] Clean --- .../CreatedPackagesRepositoryTests.cs | 5 ++-- .../Services/CachedDataTypeServiceTests.cs | 2 +- .../Services/MacroServiceTests.cs | 2 -- .../Testing/UmbracoIntegrationTest.cs | 26 ++++++------------- .../Packaging/PackageExtractionTests.cs | 4 +-- 5 files changed, 12 insertions(+), 27 deletions(-) diff --git a/src/Umbraco.Tests.Integration/Packaging/CreatedPackagesRepositoryTests.cs b/src/Umbraco.Tests.Integration/Packaging/CreatedPackagesRepositoryTests.cs index c08913298b..5bd401a5d4 100644 --- a/src/Umbraco.Tests.Integration/Packaging/CreatedPackagesRepositoryTests.cs +++ b/src/Umbraco.Tests.Integration/Packaging/CreatedPackagesRepositoryTests.cs @@ -29,12 +29,11 @@ namespace Umbraco.Tests.Packaging _testBaseFolder = Guid.NewGuid(); } - public override void TearDown() + [TearDown] + public void DeleteTestFolder() { - base.TearDown(); //clear out files/folders Directory.Delete(HostingEnvironment.MapPathContentRoot("~/" + _testBaseFolder), true); - } private IContentService ContentService => GetRequiredService(); diff --git a/src/Umbraco.Tests.Integration/Services/CachedDataTypeServiceTests.cs b/src/Umbraco.Tests.Integration/Services/CachedDataTypeServiceTests.cs index 7ff14b4697..40144cd55c 100644 --- a/src/Umbraco.Tests.Integration/Services/CachedDataTypeServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Services/CachedDataTypeServiceTests.cs @@ -28,7 +28,7 @@ namespace Umbraco.Tests.Services [Test] public void DataTypeService_Can_Get_All() { - var dataTypeService = (DataTypeService) GetRequiredService(); + var dataTypeService = GetRequiredService(); IDataType dataType = new DataType(new LabelPropertyEditor(Logger, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper)) { Name = "Testing Textfield", DatabaseType = ValueStorageType.Ntext }; dataTypeService.Save(dataType); diff --git a/src/Umbraco.Tests.Integration/Services/MacroServiceTests.cs b/src/Umbraco.Tests.Integration/Services/MacroServiceTests.cs index 2580f32b14..3dcab4c746 100644 --- a/src/Umbraco.Tests.Integration/Services/MacroServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Services/MacroServiceTests.cs @@ -29,8 +29,6 @@ namespace Umbraco.Tests.Services public void CreateTestData() { - // base.CreateTestData(); - var provider = ScopeProvider; using (var scope = provider.CreateScope()) { diff --git a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs index fb57a543ac..94c14ce2f3 100644 --- a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs +++ b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs @@ -46,7 +46,6 @@ namespace Umbraco.Tests.Integration.Testing [NonParallelizable] public abstract class UmbracoIntegrationTest { - public static LightInjectContainer CreateUmbracoContainer(out UmbracoServiceProviderFactory serviceProviderFactory) { var container = UmbracoServiceProviderFactory.CreateServiceContainer(); @@ -247,13 +246,12 @@ namespace Umbraco.Tests.Integration.Testing CustomTestSetup(services); } - public virtual void Configure(IApplicationBuilder app) { Services.GetRequiredService().EnsureBackofficeSecurity(); Services.GetRequiredService().EnsureUmbracoContext(); - - // get the currently set ptions + + // get the currently set options var testOptions = TestOptionAttributeBase.GetTestOptions(); if (testOptions.Boot) { @@ -262,7 +260,7 @@ namespace Umbraco.Tests.Integration.Testing } #endregion - + #region LocalDb @@ -347,10 +345,7 @@ namespace Umbraco.Tests.Integration.Testing var newSchemaDbId = db.AttachSchema(); // Add teardown callback - OnTestTearDown(() => - { - db.Detach(newSchemaDbId); - }); + OnTestTearDown(() => db.Detach(newSchemaDbId)); // We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings if (!databaseFactory.Configured) @@ -374,21 +369,16 @@ namespace Umbraco.Tests.Integration.Testing break; case UmbracoTestOptions.Database.NewSchemaPerFixture: - // If we try to AttachSchema before the old schema has been detached - // the process will be blocked since readyQueue remain empty - // Probably because the DB is blocked because it hasn't been detached - // Also if we attach a new schema for every test isn't it just essentially - // the same as NewSchemaPerTest? + // Only attach schema once per fixture + // Doing it more than once will block the process since the old db hasn't been detached + // and it would be the same as NewSchemaPerTest even if it didn't block if (FirstTestInFixture) { // New DB + Schema var newSchemaFixtureDbId = db.AttachSchema(); // Add teardown callback - OnFixtureTearDown(() => - { - db.Detach(newSchemaFixtureDbId); - }); + OnFixtureTearDown(() => db.Detach(newSchemaFixtureDbId)); } // We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Packaging/PackageExtractionTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Packaging/PackageExtractionTests.cs index 509d9639e3..ad76b060ce 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Packaging/PackageExtractionTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Packaging/PackageExtractionTests.cs @@ -16,9 +16,7 @@ namespace Umbraco.Tests.Packaging { const string testPackagesDirName = "Umbraco.Core\\Packaging\\Packages"; var testDir = TestContext.CurrentContext.TestDirectory.Split("bin")[0]; - var hostingEnvironment = Mock.Of( - x => x.ToAbsolute(It.IsAny()) == "/" && x.ApplicationPhysicalPath == testDir); - var path = Path.Combine(hostingEnvironment.ApplicationPhysicalPath, testPackagesDirName, packageName); + var path = Path.Combine(testDir, testPackagesDirName, packageName); return new FileInfo(path); }