mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 19:04:51 +08:00
Corrected SessionFactoryBuilder tests
--HG-- branch : dev
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using Autofac.Features.Metadata;
|
||||
using NHibernate.Tool.hbm2ddl;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Data.Providers;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
@@ -51,29 +53,35 @@ namespace Orchard.Tests.Data.Builders {
|
||||
|
||||
[Test, Ignore("Fix pending")]
|
||||
public void SqlCeSchemaShouldBeGeneratedAndUsable() {
|
||||
|
||||
var recordDescriptors = new[] {
|
||||
new RecordBlueprint {TableName = "Hello", Type = typeof (FooRecord)}
|
||||
};
|
||||
|
||||
var parameters = new SessionFactoryParameters {
|
||||
Provider = "SqlCe",
|
||||
DataFolder = _tempDataFolder,
|
||||
RecordDescriptors = recordDescriptors
|
||||
};
|
||||
|
||||
var manager = (IDataServicesProviderFactory) new DataServicesProviderFactory(new[] {
|
||||
new Meta<CreateDataServicesProvider>(
|
||||
(dataFolder, connectionString) => new SqlCeDataServicesProvider(dataFolder, connectionString),
|
||||
new Dictionary<string, object> {{"ProviderName", "SqlCe"}})
|
||||
});
|
||||
|
||||
var parameters = new SessionFactoryParameters {
|
||||
Provider = "SqlCe",
|
||||
DataFolder = _tempDataFolder,
|
||||
RecordDescriptors = recordDescriptors
|
||||
};
|
||||
var sessionFactory = manager
|
||||
var configuration = manager
|
||||
.CreateProvider(parameters)
|
||||
.BuildConfiguration(parameters)
|
||||
.BuildSessionFactory();
|
||||
.BuildConfiguration(parameters);
|
||||
|
||||
configuration.SetProperty("connection.release_mode", "on_close");
|
||||
|
||||
new SchemaExport(configuration).Execute(false, true, false);
|
||||
|
||||
var sessionFactory = configuration.BuildSessionFactory();
|
||||
|
||||
var session = sessionFactory.OpenSession();
|
||||
var foo = new FooRecord {Name = "hi there"};
|
||||
var foo = new FooRecord {Name = "hi there", Id = 1};
|
||||
session.Save(foo);
|
||||
session.Flush();
|
||||
session.Close();
|
||||
@@ -104,12 +112,14 @@ namespace Orchard.Tests.Data.Builders {
|
||||
ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFileName=" + databasePath + ";Integrated Security=True;User Instance=True;",
|
||||
RecordDescriptors = recordDescriptors,
|
||||
};
|
||||
var sessionFactory = manager
|
||||
|
||||
var configuration = manager
|
||||
.CreateProvider(parameters)
|
||||
.BuildConfiguration(parameters)
|
||||
.BuildSessionFactory();
|
||||
.BuildConfiguration(parameters);
|
||||
|
||||
new SchemaExport(configuration).Execute(false, true, false);
|
||||
|
||||
var sessionFactory = configuration.BuildSessionFactory();
|
||||
|
||||
var session = sessionFactory.OpenSession();
|
||||
var foo = new FooRecord { Name = "hi there" };
|
||||
|
Reference in New Issue
Block a user