From b8f455e50bdcaa058f985d67138638efa780080b Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Thu, 10 Jan 2013 04:49:12 +0300 Subject: [PATCH] Removed PluginManagerExtensions for finding IMigrations since we are manually initializing the resolver instead of type finding. Updated unit tests to use resolvers and are passing. --- .../Migrations/PluginManagerExtension.cs | 13 ------ src/Umbraco.Core/Umbraco.Core.csproj | 1 - .../Migrations/FindingMigrationsTest.cs | 36 ++++++++-------- .../Migrations/PluginManagerExtensions.cs | 24 ----------- .../TargetVersionSixthMigrationsTest.cs | 41 ++++++++++--------- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 6 files changed, 38 insertions(+), 78 deletions(-) delete mode 100644 src/Umbraco.Core/Persistence/Migrations/PluginManagerExtension.cs delete mode 100644 src/Umbraco.Tests/Migrations/PluginManagerExtensions.cs diff --git a/src/Umbraco.Core/Persistence/Migrations/PluginManagerExtension.cs b/src/Umbraco.Core/Persistence/Migrations/PluginManagerExtension.cs deleted file mode 100644 index 8540f8dbf7..0000000000 --- a/src/Umbraco.Core/Persistence/Migrations/PluginManagerExtension.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; - -namespace Umbraco.Core.Persistence.Migrations -{ - internal static class PluginManagerExtension - { - public static IEnumerable FindMigrations(this PluginManager resolver) - { - var types = resolver.ResolveTypesWithAttribute(); - return resolver.CreateInstances(types); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index bcc78b02e8..18ca0566c8 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -267,7 +267,6 @@ - diff --git a/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs b/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs index c148ec222e..7239f21fc1 100644 --- a/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs +++ b/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using NUnit.Framework; using Umbraco.Core; +using Umbraco.Core.ObjectResolution; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Migrations; using Umbraco.Core.Persistence.SqlSyntax; @@ -19,31 +20,25 @@ namespace Umbraco.Tests.Migrations { TestHelper.SetupLog4NetForTests(); - //this ensures its reset - PluginManager.Current = new PluginManager(false); + MigrationResolver.Current = new MigrationResolver(new List + { + typeof (AlterUserTableMigrationStub), + typeof(Dummy), + typeof (FourNineMigration), + typeof (FourTenMigration), + typeof (FourElevenMigration), + typeof (FourElevenMigration) + }); - //for testing, we'll specify which assemblies are scanned for the PluginTypeResolver - PluginManager.Current.AssembliesToScan = new[] - { - typeof (FourNineMigration).Assembly - }; + Resolution.Freeze(); SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider; - } - - [Test] - public void Can_Find_Migrations_In_Current_Assembly() - { - var foundTypes = PluginManager.Current.ResolveMigrationTypes(); - - Assert.That(foundTypes.Any(), Is.True); - Assert.That(foundTypes.Count(), Is.EqualTo(4)); - } + } [Test] public void Can_Find_Migrations_With_Targtet_Version_Six() { - var foundMigrations = PluginManager.Current.FindMigrations(); + var foundMigrations = MigrationResolver.Current.Migrations; var targetVersion = new Version("6.0.0"); var list = new List(); @@ -78,8 +73,9 @@ namespace Umbraco.Tests.Migrations [TearDown] public void TearDown() - { - PluginManager.Current = null; + { + MigrationResolver.Reset(); + Resolution.IsFrozen = false; } } } \ No newline at end of file diff --git a/src/Umbraco.Tests/Migrations/PluginManagerExtensions.cs b/src/Umbraco.Tests/Migrations/PluginManagerExtensions.cs deleted file mode 100644 index 77b63703b0..0000000000 --- a/src/Umbraco.Tests/Migrations/PluginManagerExtensions.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using Umbraco.Core; -using Umbraco.Core.Persistence.Migrations; - -namespace Umbraco.Tests.Migrations -{ - /// - /// Used for TypeInheritanceTest and CodeFirstTests - /// - internal static class PluginManagerExtensions - { - public static IEnumerable ResolveMigrationTypes(this PluginManager resolver) - { - return resolver.ResolveTypesWithAttribute(); - } - - public static IEnumerable FindMigrations(this PluginManager resolver) - { - var types = resolver.ResolveTypesWithAttribute(); - return resolver.CreateInstances(types); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs b/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs index 2b15022dd6..a1e02bc18a 100644 --- a/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs +++ b/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs @@ -1,7 +1,9 @@ using System; +using System.Collections.Generic; using System.Linq; using NUnit.Framework; using Umbraco.Core; +using Umbraco.Core.ObjectResolution; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Migrations; using Umbraco.Core.Persistence.SqlSyntax; @@ -18,33 +20,33 @@ namespace Umbraco.Tests.Migrations { TestHelper.SetupLog4NetForTests(); - //this ensures its reset - PluginManager.Current = new PluginManager(false); + MigrationResolver.Current = new MigrationResolver(new List + { + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionFourNineZero.RemoveUmbracoAppConstraints), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.DeleteAppTables), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.EnsureAppsTreesUpdated), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.MoveMasterContentTypeData), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.NewCmsContentType2ContentTypeTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RemoveMasterContentTypeColumn), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RenameCmsTabTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RenameTabIdColumn), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentTypeAllowedContentTypeTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentTypeTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentVersionTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsPropertyTypeGroupTable) + }); - //for testing, we'll specify which assemblies are scanned for the PluginTypeResolver - PluginManager.Current.AssembliesToScan = new[] - { - typeof (MigrationRunner).Assembly - }; + Resolution.Freeze(); SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider; } - - [Test] - public void Can_Find_Migrations_In_Current_Assembly() - { - var foundTypes = PluginManager.Current.ResolveMigrationTypes(); - - Assert.That(foundTypes.Any(), Is.True); - Assert.That(foundTypes.Count(), Is.GreaterThanOrEqualTo(11)); - } - + [Test] public void Can_Find_Targetted_Migrations() { var configuredVersion = new Version("4.11.0"); var targetVersion = new Version("6.0.0"); - var foundMigrations = PluginManager.Current.FindMigrations(); + var foundMigrations = MigrationResolver.Current.Migrations; var migrationRunner = new MigrationRunner(configuredVersion, targetVersion, GlobalSettings.UmbracoMigrationName); var migrations = migrationRunner.OrderedUpgradeMigrations(foundMigrations); @@ -66,7 +68,8 @@ namespace Umbraco.Tests.Migrations [TearDown] public void TearDown() { - PluginManager.Current = null; + MigrationResolver.Reset(); + Resolution.IsFrozen = false; } } } \ No newline at end of file diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 9770fe643e..95c7b5bd12 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -168,7 +168,6 @@ SqlResources.resx -