mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fix a few data migration unit tests
--HG-- branch : dev
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using Autofac;
|
||||
using NHibernate;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Data;
|
||||
using Orchard.Data.Migration.Interpreters;
|
||||
using Orchard.Data.Migration.Schema;
|
||||
using Orchard.Data.Providers;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
using Orchard.FileSystems.AppData;
|
||||
using Orchard.Reports.Services;
|
||||
using Orchard.Tests.ContentManagement;
|
||||
using System.IO;
|
||||
using Orchard.Tests.FileSystems.AppData;
|
||||
using Orchard.Tests.Stubs;
|
||||
|
||||
namespace Orchard.Tests.DataMigration {
|
||||
[TestFixture]
|
||||
@@ -15,24 +22,35 @@ namespace Orchard.Tests.DataMigration {
|
||||
private IContainer _container;
|
||||
private ISessionFactory _sessionFactory;
|
||||
private string _databaseFileName;
|
||||
private string _tempFolder;
|
||||
private SchemaBuilder _schemaBuilder;
|
||||
private DefaultDataMigrationInterpreter _interpreter;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() {
|
||||
_databaseFileName = Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(
|
||||
_databaseFileName);
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(_databaseFileName);
|
||||
|
||||
_tempFolder = Path.GetTempFileName();
|
||||
File.Delete(_tempFolder);
|
||||
var appDataFolder = AppDataFolderTests.CreateAppDataFolder(_tempFolder);
|
||||
|
||||
var builder = new ContainerBuilder();
|
||||
|
||||
builder.RegisterInstance(new ShellSettings { DataTablePrefix = "TEST_", DataProvider = "SqlCe" });
|
||||
|
||||
var session = _sessionFactory.OpenSession();
|
||||
builder.RegisterInstance(appDataFolder).As<IAppDataFolder>();
|
||||
builder.RegisterType<SqlCeDataServicesProvider>().As<IDataServicesProvider>();
|
||||
builder.RegisterType<DataServicesProviderFactory>().As<IDataServicesProviderFactory>();
|
||||
builder.RegisterType<StubReportsCoordinator>().As<IReportsCoordinator>();
|
||||
builder.RegisterType<DefaultDataMigrationInterpreter>().As<IDataMigrationInterpreter>();
|
||||
builder.RegisterType<SessionFactoryHolder>().As<ISessionFactoryHolder>();
|
||||
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(session)).As<ISessionLocator>();
|
||||
builder.RegisterInstance(new ShellSettings { DataProvider = "SqlCe", DataTablePrefix = "TEST_" }).As<ShellSettings>();
|
||||
builder.RegisterInstance(new ShellBlueprint { Records = Enumerable.Empty<RecordBlueprint>() }).As<ShellBlueprint>();
|
||||
builder.RegisterInstance(new ShellSettings { Name = "temp", DataProvider = "SqlCe", DataTablePrefix = "TEST_" }).As<ShellSettings>();
|
||||
builder.RegisterType<SqlCeCommandInterpreter>().As<ICommandInterpreter>();
|
||||
builder.RegisterModule(new DataModule());
|
||||
_container = builder.Build();
|
||||
|
||||
_interpreter = _container.Resolve<IDataMigrationInterpreter>() as DefaultDataMigrationInterpreter;
|
||||
@@ -71,7 +89,7 @@ namespace Orchard.Tests.DataMigration {
|
||||
|
||||
[Test]
|
||||
public void CreateCommandShouldBeHandled() {
|
||||
|
||||
|
||||
_schemaBuilder
|
||||
.CreateTable("User", table => table
|
||||
.Column("Id", DbType.Int32, column => column.PrimaryKey().Identity())
|
||||
|
@@ -208,6 +208,7 @@
|
||||
<Compile Include="Mvc\Html\HtmlHelperExtensionsTests.cs" />
|
||||
<Compile Include="Mvc\Routes\ShellRouteTests.cs" />
|
||||
<Compile Include="Mvc\Routes\UrlPrefixTests.cs" />
|
||||
<Compile Include="Stubs\StubReportsCoordinator.cs" />
|
||||
<Compile Include="Stubs\StubVirtualPathProvider.cs" />
|
||||
<Compile Include="Stubs\StubFileSystem.cs" />
|
||||
<Compile Include="Stubs\StubAppDataFolder.cs" />
|
||||
|
14
src/Orchard.Tests/Stubs/StubReportsCoordinator.cs
Normal file
14
src/Orchard.Tests/Stubs/StubReportsCoordinator.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Orchard.Reports;
|
||||
using Orchard.Reports.Services;
|
||||
|
||||
namespace Orchard.Tests.Stubs {
|
||||
public class StubReportsCoordinator : IReportsCoordinator {
|
||||
public void Add(string reportKey, ReportEntryType type, string message) {
|
||||
|
||||
}
|
||||
|
||||
public void Register(string reportKey, string activityName, string title) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,20 +21,16 @@ namespace Orchard.Data.Migration {
|
||||
private readonly IRepository<DataMigrationRecord> _dataMigrationRepository;
|
||||
private readonly IExtensionManager _extensionManager;
|
||||
private readonly IDataMigrationInterpreter _interpreter;
|
||||
private readonly IReportsCoordinator _reportsCoordinator;
|
||||
|
||||
public DataMigrationManager(
|
||||
IEnumerable<IDataMigration> dataMigrations,
|
||||
IRepository<DataMigrationRecord> dataMigrationRepository,
|
||||
IExtensionManager extensionManager,
|
||||
IDataMigrationInterpreter interpreter,
|
||||
IReportsCoordinator reportsCoordinator
|
||||
) {
|
||||
IDataMigrationInterpreter interpreter) {
|
||||
_dataMigrations = dataMigrations;
|
||||
_dataMigrationRepository = dataMigrationRepository;
|
||||
_extensionManager = extensionManager;
|
||||
_interpreter = interpreter;
|
||||
_reportsCoordinator = reportsCoordinator;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
Reference in New Issue
Block a user