now only 24 tests failing, that's pretty good!
This commit is contained in:
@@ -486,7 +486,7 @@ javascript: ['~/test.js',/*** some note about stuff asd09823-4**09234*/ '~/test2
|
||||
var content4 = "{propertyEditors: [], javascript: ['~/test.js', '~/test2.js']}";
|
||||
var content5 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble()) + "{propertyEditors: [], javascript: ['~/test.js', '~/test2.js']}";
|
||||
|
||||
var result = _parser.CreateManifests(null, content1, content2, content3, content4);
|
||||
var result = _parser.CreateManifests(null, content1, content2, content3, content4, content5);
|
||||
|
||||
Assert.AreEqual(5, result.Count());
|
||||
Assert.AreEqual(0, result.ElementAt(1).JavaScriptInitialize.Count);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using LightInject;
|
||||
using Moq;
|
||||
@@ -13,42 +14,31 @@ using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Core.Profiling;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.Migrations.Stubs;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
|
||||
namespace Umbraco.Tests.Migrations
|
||||
{
|
||||
[TestFixture]
|
||||
public class FindingMigrationsTest
|
||||
public class FindingMigrationsTest : BaseDatabaseFactoryTest
|
||||
{
|
||||
private MigrationResolver _migrationResolver;
|
||||
|
||||
[SetUp]
|
||||
public void Initialize()
|
||||
{
|
||||
var container = new ServiceContainer();
|
||||
container.Register<ILogger>(factory => Mock.Of<ILogger>(), new PerContainerLifetime());
|
||||
container.Register<ISqlSyntaxProvider>(factory => Mock.Of<ISqlSyntaxProvider>(), new PerContainerLifetime());
|
||||
|
||||
_migrationResolver = new MigrationResolver(
|
||||
container,
|
||||
Mock.Of<ILogger>(),
|
||||
() => new List<Type>
|
||||
{
|
||||
typeof (AlterUserTableMigrationStub),
|
||||
typeof(Dummy),
|
||||
typeof (SixZeroMigration1),
|
||||
typeof (SixZeroMigration2),
|
||||
typeof (FourElevenMigration),
|
||||
typeof (FiveZeroMigration)
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Find_Migrations_With_Target_Version_Six()
|
||||
{
|
||||
var foundMigrations = _migrationResolver.Migrations;
|
||||
var migrationResolver = new MigrationResolver(
|
||||
Container,
|
||||
Logger,
|
||||
() => new List<Type>
|
||||
{
|
||||
typeof (AlterUserTableMigrationStub),
|
||||
typeof(Dummy),
|
||||
typeof (SixZeroMigration1),
|
||||
typeof (SixZeroMigration2),
|
||||
typeof (FourElevenMigration),
|
||||
typeof (FiveZeroMigration)
|
||||
});
|
||||
|
||||
var foundMigrations = migrationResolver.Migrations;
|
||||
var targetVersion = new Version("6.0.0");
|
||||
var list = new List<IMigration>();
|
||||
|
||||
@@ -66,7 +56,7 @@ namespace Umbraco.Tests.Migrations
|
||||
|
||||
Assert.That(list.Count, Is.EqualTo(3));
|
||||
|
||||
var context = new MigrationContext(DatabaseProviders.SqlServerCE, null, Mock.Of<ILogger>(), Mock.Of<ISqlSyntaxProvider>());
|
||||
var context = new MigrationContext(DatabaseProviders.SqlServerCE, DatabaseContext.Database, Logger, SqlSyntax);
|
||||
foreach (var migration1 in list)
|
||||
{
|
||||
var migration = (MigrationBase) migration1;
|
||||
@@ -81,12 +71,5 @@ namespace Umbraco.Tests.Migrations
|
||||
Console.WriteLine(expression.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
LoggerResolver.Reset();
|
||||
MigrationResolver.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlServerCe;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Semver;
|
||||
using SQLCE4Umbraco;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.ObjectResolution;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Migrations;
|
||||
using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using GlobalSettings = Umbraco.Core.Configuration.GlobalSettings;
|
||||
|
||||
namespace Umbraco.Tests.Migrations
|
||||
{
|
||||
[DatabaseTestBehavior(DatabaseBehavior.EmptyDbFilePerTest)]
|
||||
[TestFixture]
|
||||
public class TargetVersionSixthMigrationsTest : BaseDatabaseFactoryTest
|
||||
{
|
||||
/// <summary>Regular expression that finds multiline block comments.</summary>
|
||||
private static readonly Regex FindComments = new Regex(@"\/\*.*?\*\/", RegexOptions.Singleline | RegexOptions.Compiled);
|
||||
|
||||
private MigrationResolver _migrationResolver;
|
||||
/// <summary>
|
||||
/// sets up resolvers before resolution is frozen
|
||||
/// </summary>
|
||||
protected override void FreezeResolution()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
|
||||
_migrationResolver = new MigrationResolver(
|
||||
Container,
|
||||
ProfilingLogger.Logger,
|
||||
() => new List<Type>
|
||||
{
|
||||
typeof (Core.Persistence.Migrations.Upgrades.TargetVersionFourNineZero.RemoveUmbracoAppConstraints),
|
||||
typeof (DeleteAppTables),
|
||||
typeof (EnsureAppsTreesUpdated),
|
||||
typeof (MoveMasterContentTypeData),
|
||||
typeof (NewCmsContentType2ContentTypeTable),
|
||||
typeof (RemoveMasterContentTypeColumn),
|
||||
typeof (RenameCmsTabTable),
|
||||
typeof (RenameTabIdColumn),
|
||||
typeof (UpdateCmsContentTypeAllowedContentTypeTable),
|
||||
typeof (UpdateCmsContentTypeTable),
|
||||
typeof (UpdateCmsContentVersionTable),
|
||||
typeof (UpdateCmsPropertyTypeGroupTable)
|
||||
}.OrderByDescending(x => x.Name));
|
||||
|
||||
var engine = new SqlCeEngine("Datasource=|DataDirectory|UmbracoPetaPocoTests.sdf;Flush Interval=1;");
|
||||
engine.CreateDatabase();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Find_Targetted_Migrations()
|
||||
{
|
||||
var db = GetConfiguredDatabase();
|
||||
|
||||
//Create db schema and data from old Total.sql file for Sql Ce
|
||||
string statements = GetDatabaseSpecificSqlScript();
|
||||
// replace block comments by whitespace
|
||||
statements = FindComments.Replace(statements, " ");
|
||||
// execute all non-empty statements
|
||||
foreach (string statement in statements.Split(";".ToCharArray()))
|
||||
{
|
||||
string rawStatement = statement.Replace("GO", "").Trim();
|
||||
if (rawStatement.Length > 0)
|
||||
db.Execute(new Sql(rawStatement));
|
||||
}
|
||||
|
||||
var configuredVersion = new SemVersion(4, 8, 0);
|
||||
var targetVersion = new SemVersion(6, 0, 0);
|
||||
var foundMigrations = _migrationResolver.Migrations;
|
||||
|
||||
var migrationRunner = new MigrationRunner(
|
||||
Mock.Of<IMigrationResolver>(),
|
||||
Mock.Of<IMigrationEntryService>(),
|
||||
Logger, configuredVersion, targetVersion, GlobalSettings.UmbracoMigrationName);
|
||||
|
||||
var migrations = migrationRunner.OrderedUpgradeMigrations(foundMigrations).ToList();
|
||||
|
||||
var context = new MigrationContext(DatabaseProviders.SqlServerCE, db, Logger, SqlSyntax);
|
||||
foreach (var migration1 in migrations)
|
||||
{
|
||||
var migration = (MigrationBase) migration1;
|
||||
migration.GetUpExpressions(context);
|
||||
}
|
||||
|
||||
foreach (var expression in context.Expressions)
|
||||
{
|
||||
Console.WriteLine(expression.ToString());
|
||||
}
|
||||
|
||||
Assert.That(migrations.Count(), Is.EqualTo(12));
|
||||
}
|
||||
|
||||
public string Path { get; set; }
|
||||
|
||||
public UmbracoDatabase GetConfiguredDatabase()
|
||||
{
|
||||
return new UmbracoDatabase("Datasource=|DataDirectory|UmbracoPetaPocoTests.sdf;Flush Interval=1;", "System.Data.SqlServerCe.4.0", Mock.Of<ILogger>());
|
||||
}
|
||||
|
||||
|
||||
public string GetDatabaseSpecificSqlScript()
|
||||
{
|
||||
return SqlScripts.SqlResources.SqlCeTotal_480;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,7 +347,6 @@
|
||||
<Compile Include="Migrations\Stubs\AlterUserTableMigrationStub.cs" />
|
||||
<Compile Include="Migrations\Stubs\Dummy.cs" />
|
||||
<Compile Include="Migrations\Stubs\SixZeroMigration1.cs" />
|
||||
<Compile Include="Migrations\TargetVersionSixthMigrationsTest.cs" />
|
||||
<Compile Include="Migrations\Upgrades\MySqlUpgradeTest.cs" />
|
||||
<Compile Include="Migrations\Upgrades\SqlCeDataUpgradeTest.cs" />
|
||||
<Compile Include="Migrations\Upgrades\SqlCeUpgradeTest.cs" />
|
||||
|
||||
Reference in New Issue
Block a user