|
From: <fab...@us...> - 2009-07-01 16:31:21
|
Revision: 4551
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4551&view=rev
Author: fabiomaulo
Date: 2009-07-01 16:31:18 +0000 (Wed, 01 Jul 2009)
Log Message:
-----------
Fluent configuration implemented
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs
trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs
trunk/nhibernate/src/NHibernate/ConnectionReleaseMode.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2009-07-01 13:46:24 UTC (rev 4550)
+++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2009-07-01 16:31:18 UTC (rev 4551)
@@ -4,7 +4,7 @@
{
public static IFluentSessionFactoryConfiguration SessionFactory(this Configuration configuration)
{
- return null;
+ return new FluentSessionFactoryConfiguration(configuration);
}
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs 2009-07-01 16:31:18 UTC (rev 4551)
@@ -0,0 +1,470 @@
+using System.Data;
+using System.Data.Common;
+using NHibernate.AdoNet;
+using NHibernate.Bytecode;
+using NHibernate.Cache;
+using NHibernate.Connection;
+using NHibernate.Driver;
+using NHibernate.Exceptions;
+using NHibernate.Hql;
+using NHibernate.Transaction;
+
+namespace NHibernate.Cfg.Loquacious
+{
+ internal class FluentSessionFactoryConfiguration : IFluentSessionFactoryConfiguration
+ {
+ private readonly Configuration configuration;
+
+ public FluentSessionFactoryConfiguration(Configuration configuration)
+ {
+ this.configuration = configuration;
+ Integrate = new DbIntegrationConfiguration(configuration);
+ Caching = new CacheConfiguration(this);
+ Proxy = new ProxyConfiguration(this);
+ GeneratingCollections = new CollectionFactoryConfiguration(this);
+ Mapping = new MappingsConfiguration(this);
+ }
+
+ internal Configuration Configuration
+ {
+ get { return configuration; }
+ }
+
+ #region Implementation of IFluentSessionFactoryConfiguration
+
+ public IFluentSessionFactoryConfiguration Named(string sessionFactoryName)
+ {
+ configuration.SetProperty(Environment.SessionFactoryName, sessionFactoryName);
+ return this;
+ }
+
+ public IDbIntegrationConfiguration Integrate { get; private set; }
+
+ public ICacheConfiguration Caching { get; private set; }
+
+ public IFluentSessionFactoryConfiguration GenerateStatistics()
+ {
+ configuration.SetProperty(Environment.GenerateStatistics, "true");
+ return this;
+ }
+
+ public IFluentSessionFactoryConfiguration Using(EntityMode entityMode)
+ {
+ configuration.SetProperty(Environment.DefaultEntityMode, EntityModeHelper.ToString(entityMode));
+ return this;
+ }
+
+ public IFluentSessionFactoryConfiguration ParsingHqlThrough<TQueryTranslator>()
+ where TQueryTranslator : IQueryTranslatorFactory
+ {
+ configuration.SetProperty(Environment.QueryTranslator, typeof (TQueryTranslator).AssemblyQualifiedName);
+ return this;
+ }
+
+ public IProxyConfiguration Proxy { get; private set; }
+ public ICollectionFactoryConfiguration GeneratingCollections { get; private set; }
+ public IMappingsConfiguration Mapping { get; private set; }
+
+ #endregion
+ }
+
+ internal class DbIntegrationConfiguration : IDbIntegrationConfiguration
+ {
+ private readonly Configuration configuration;
+
+ public DbIntegrationConfiguration(Configuration configuration)
+ {
+ this.configuration = configuration;
+ Connected = new ConnectionConfiguration(this);
+ BatchingQueries = new BatcherConfiguration(this);
+ Transactions = new TransactionConfiguration(this);
+ CreateCommands = new CommandsConfiguration(this);
+ Schema = new DbSchemaIntegrationConfiguration(this);
+ }
+
+ public Configuration Configuration
+ {
+ get { return configuration; }
+ }
+
+ #region Implementation of IDbIntegrationConfiguration
+
+ public IDbIntegrationConfiguration Using<TDialect>() where TDialect : Dialect.Dialect
+ {
+ configuration.SetProperty(Environment.Dialect, typeof (TDialect).AssemblyQualifiedName);
+ return this;
+ }
+
+ public IDbIntegrationConfiguration DisableKeywordsAutoImport()
+ {
+ configuration.SetProperty(Environment.Hbm2ddlKeyWords, "none");
+ return this;
+ }
+
+ public IDbIntegrationConfiguration AutoQuoteKeywords()
+ {
+ configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote");
+ return this;
+ }
+
+ public IDbIntegrationConfiguration LogSqlInConsole()
+ {
+ configuration.SetProperty(Environment.ShowSql, "true");
+ return this;
+ }
+
+ public IDbIntegrationConfiguration DisableLogFormatedSql()
+ {
+ configuration.SetProperty(Environment.FormatSql, "false");
+ return this;
+ }
+
+ public IConnectionConfiguration Connected { get; private set; }
+ public IBatcherConfiguration BatchingQueries { get; private set; }
+ public ITransactionConfiguration Transactions { get; private set; }
+
+ public ICommandsConfiguration CreateCommands { get; private set; }
+
+ public IDbSchemaIntegrationConfiguration Schema { get; private set; }
+
+ #endregion
+ }
+
+ internal class DbSchemaIntegrationConfiguration : IDbSchemaIntegrationConfiguration
+ {
+ private readonly DbIntegrationConfiguration dbc;
+
+ public DbSchemaIntegrationConfiguration(DbIntegrationConfiguration dbc)
+ {
+ this.dbc = dbc;
+ }
+
+ #region Implementation of IDbSchemaIntegrationConfiguration
+
+ public IDbIntegrationConfiguration Recreating()
+ {
+ dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "create-drop");
+ return dbc;
+ }
+
+ public IDbIntegrationConfiguration Creating()
+ {
+ dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "create");
+ return dbc;
+ }
+
+ public IDbIntegrationConfiguration Updating()
+ {
+ dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "update");
+ return dbc;
+ }
+
+ public IDbIntegrationConfiguration Validating()
+ {
+ dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "validate");
+ return dbc;
+ }
+
+ #endregion
+ }
+
+ internal class CommandsConfiguration : ICommandsConfiguration
+ {
+ private readonly DbIntegrationConfiguration dbc;
+
+ public CommandsConfiguration(DbIntegrationConfiguration dbc)
+ {
+ this.dbc = dbc;
+ }
+
+ #region Implementation of ICommandsConfiguration
+
+ public ICommandsConfiguration Preparing()
+ {
+ dbc.Configuration.SetProperty(Environment.PrepareSql, "true");
+ return this;
+ }
+
+ public ICommandsConfiguration WithTimeout(int seconds)
+ {
+ dbc.Configuration.SetProperty(Environment.CommandTimeout, seconds.ToString());
+ return this;
+ }
+
+ public ICommandsConfiguration ConvertingExceptionsThrough<TExceptionConverter>()
+ where TExceptionConverter : ISQLExceptionConverter
+ {
+ dbc.Configuration.SetProperty(Environment.SqlExceptionConverter, typeof (TExceptionConverter).AssemblyQualifiedName);
+ return this;
+ }
+
+ public ICommandsConfiguration AutoCommentingSql()
+ {
+ dbc.Configuration.SetProperty(Environment.UseSqlComments, "true");
+ return this;
+ }
+
+ public IDbIntegrationConfiguration WithHqlToSqlSubstitutions(string csvQuerySubstitutions)
+ {
+ dbc.Configuration.SetProperty(Environment.QuerySubstitutions, csvQuerySubstitutions);
+ return dbc;
+ }
+
+ public IDbIntegrationConfiguration WithDefaultHqlToSqlSubstitutions()
+ {
+ return dbc;
+ }
+
+ public ICommandsConfiguration WithMaximumDepthOfOuterJoinFetching(byte maxFetchDepth)
+ {
+ dbc.Configuration.SetProperty(Environment.MaxFetchDepth, maxFetchDepth.ToString());
+ return this;
+ }
+
+ #endregion
+ }
+
+ internal class TransactionConfiguration : ITransactionConfiguration
+ {
+ private readonly DbIntegrationConfiguration dbc;
+
+ public TransactionConfiguration(DbIntegrationConfiguration dbc)
+ {
+ this.dbc = dbc;
+ }
+
+ #region Implementation of ITransactionConfiguration
+
+ public IDbIntegrationConfiguration Through<TFactory>() where TFactory : ITransactionFactory
+ {
+ dbc.Configuration.SetProperty(Environment.TransactionStrategy, typeof (TFactory).AssemblyQualifiedName);
+ return dbc;
+ }
+
+ #endregion
+ }
+
+ internal class BatcherConfiguration : IBatcherConfiguration
+ {
+ private readonly DbIntegrationConfiguration dbc;
+
+ public BatcherConfiguration(DbIntegrationConfiguration dbc)
+ {
+ this.dbc = dbc;
+ }
+
+ #region Implementation of IBatcherConfiguration
+
+ public IBatcherConfiguration Through<TBatcher>() where TBatcher : IBatcherFactory
+ {
+ dbc.Configuration.SetProperty(Environment.BatchStrategy, typeof (TBatcher).AssemblyQualifiedName);
+ return this;
+ }
+
+ public IDbIntegrationConfiguration Each(short batchSize)
+ {
+ dbc.Configuration.SetProperty(Environment.BatchSize, batchSize.ToString());
+ return dbc;
+ }
+
+ #endregion
+ }
+
+ internal class ConnectionConfiguration : IConnectionConfiguration
+ {
+ private readonly DbIntegrationConfiguration dbc;
+
+ public ConnectionConfiguration(DbIntegrationConfiguration dbc)
+ {
+ this.dbc = dbc;
+ }
+
+ #region Implementation of IConnectionConfiguration
+
+ public IConnectionConfiguration Through<TProvider>() where TProvider : IConnectionProvider
+ {
+ dbc.Configuration.SetProperty(Environment.ConnectionProvider, typeof (TProvider).AssemblyQualifiedName);
+ return this;
+ }
+
+ public IConnectionConfiguration By<TDriver>() where TDriver : IDriver
+ {
+ dbc.Configuration.SetProperty(Environment.ConnectionDriver, typeof (TDriver).AssemblyQualifiedName);
+ return this;
+ }
+
+ public IConnectionConfiguration With(IsolationLevel level)
+ {
+ dbc.Configuration.SetProperty(Environment.Isolation, level.ToString());
+ return this;
+ }
+
+ public IConnectionConfiguration Releasing(ConnectionReleaseMode releaseMode)
+ {
+ dbc.Configuration.SetProperty(Environment.ReleaseConnections, ConnectionReleaseModeParser.ToString(releaseMode));
+ return this;
+ }
+
+ public IDbIntegrationConfiguration Using(string connectionString)
+ {
+ dbc.Configuration.SetProperty(Environment.ConnectionString, connectionString);
+ return dbc;
+ }
+
+ public IDbIntegrationConfiguration Using(DbConnectionStringBuilder connectionStringBuilder)
+ {
+ dbc.Configuration.SetProperty(Environment.ConnectionString, connectionStringBuilder.ConnectionString);
+ return dbc;
+ }
+
+ public IDbIntegrationConfiguration ByAppConfing(string connectionStringName)
+ {
+ dbc.Configuration.SetProperty(Environment.ConnectionStringName, connectionStringName);
+ return dbc;
+ }
+
+ #endregion
+ }
+
+ internal class CacheConfiguration : ICacheConfiguration
+ {
+ private readonly FluentSessionFactoryConfiguration fc;
+
+ public CacheConfiguration(FluentSessionFactoryConfiguration parent)
+ {
+ fc = parent;
+ Queries = new QueryCacheConfiguration(this);
+ }
+
+ internal Configuration Configuration
+ {
+ get { return fc.Configuration; }
+ }
+
+ #region Implementation of ICacheConfiguration
+
+ public ICacheConfiguration Through<TProvider>() where TProvider : ICacheProvider
+ {
+ fc.Configuration.SetProperty(Environment.CacheProvider, typeof (TProvider).AssemblyQualifiedName);
+ return this;
+ }
+
+ public ICacheConfiguration PrefixingRegionsWith(string regionPrefix)
+ {
+ fc.Configuration.SetProperty(Environment.CacheRegionPrefix, regionPrefix);
+ return this;
+ }
+
+ public ICacheConfiguration UsingMinimalPuts()
+ {
+ fc.Configuration.SetProperty(Environment.UseMinimalPuts, "true");
+ return this;
+ }
+
+ public IFluentSessionFactoryConfiguration WithDefaultExpiration(byte seconds)
+ {
+ fc.Configuration.SetProperty(Environment.CacheDefaultExpiration, seconds.ToString());
+ return fc;
+ }
+
+ public IQueryCacheConfiguration Queries { get; private set; }
+
+ #endregion
+ }
+
+ internal class QueryCacheConfiguration : IQueryCacheConfiguration
+ {
+ private readonly CacheConfiguration cc;
+
+ public QueryCacheConfiguration(CacheConfiguration cc)
+ {
+ this.cc = cc;
+ }
+
+ #region Implementation of IQueryCacheConfiguration
+
+ public ICacheConfiguration Through<TFactory>() where TFactory : IQueryCache
+ {
+ cc.Configuration.SetProperty(Environment.QueryCacheFactory, typeof (TFactory).AssemblyQualifiedName);
+ return cc;
+ }
+
+ #endregion
+ }
+
+ internal class ProxyConfiguration : IProxyConfiguration
+ {
+ private readonly FluentSessionFactoryConfiguration fc;
+
+ public ProxyConfiguration(FluentSessionFactoryConfiguration parent)
+ {
+ fc = parent;
+ }
+
+ #region Implementation of IProxyConfiguration
+
+ public IProxyConfiguration DisableValidation()
+ {
+ fc.Configuration.SetProperty(Environment.UseProxyValidator, "false");
+ return this;
+ }
+
+ public IFluentSessionFactoryConfiguration Through<TProxyFactoryFactory>()
+ where TProxyFactoryFactory : IProxyFactoryFactory
+ {
+ fc.Configuration.SetProperty(Environment.ProxyFactoryFactoryClass,
+ typeof (TProxyFactoryFactory).AssemblyQualifiedName);
+ return fc;
+ }
+
+ #endregion
+ }
+
+ internal class CollectionFactoryConfiguration : ICollectionFactoryConfiguration
+ {
+ private readonly FluentSessionFactoryConfiguration fc;
+
+ public CollectionFactoryConfiguration(FluentSessionFactoryConfiguration parent)
+ {
+ fc = parent;
+ }
+
+ #region Implementation of ICollectionFactoryConfiguration
+
+ public IFluentSessionFactoryConfiguration Through<TCollecionsFactory>()
+ where TCollecionsFactory : ICollectionTypeFactory
+ {
+ fc.Configuration.SetProperty(Environment.CollectionTypeFactoryClass,
+ typeof (TCollecionsFactory).AssemblyQualifiedName);
+ return fc;
+ }
+
+ #endregion
+ }
+
+ internal class MappingsConfiguration : IMappingsConfiguration
+ {
+ private readonly FluentSessionFactoryConfiguration fc;
+
+ public MappingsConfiguration(FluentSessionFactoryConfiguration parent)
+ {
+ fc = parent;
+ }
+
+ #region Implementation of IMappingsConfiguration
+
+ public IMappingsConfiguration UsingDefaultCatalog(string defaultCatalogName)
+ {
+ fc.Configuration.SetProperty(Environment.DefaultCatalog, defaultCatalogName);
+ return this;
+ }
+
+ public IFluentSessionFactoryConfiguration UsingDefaultSchema(string defaultSchemaName)
+ {
+ fc.Configuration.SetProperty(Environment.DefaultSchema, defaultSchemaName);
+ return fc;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2009-07-01 13:46:24 UTC (rev 4550)
+++ trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2009-07-01 16:31:18 UTC (rev 4551)
@@ -95,7 +95,7 @@
}
else
{
- releaseMode = ParseConnectionReleaseMode(releaseModeName);
+ releaseMode = ConnectionReleaseModeParser.Convert(releaseModeName);
}
settings.ConnectionReleaseMode = releaseMode;
@@ -329,21 +329,6 @@
}
}
- private static ConnectionReleaseMode ParseConnectionReleaseMode(string name)
- {
- switch (name)
- {
- case "after_statement":
- throw new HibernateException("aggressive connection release (after_statement) not supported by NHibernate");
- case "after_transaction":
- return ConnectionReleaseMode.AfterTransaction;
- case "on_close":
- return ConnectionReleaseMode.OnClose;
- default:
- throw new HibernateException("could not determine appropriate connection release mode [" + name + "]");
- }
- }
-
// visibility changed and static modifier added until complete H3.2 porting of SettingsFactory
private static IQueryTranslatorFactory CreateQueryTranslatorFactory(IDictionary<string, string> properties)
{
Modified: trunk/nhibernate/src/NHibernate/ConnectionReleaseMode.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/ConnectionReleaseMode.cs 2009-07-01 13:46:24 UTC (rev 4550)
+++ trunk/nhibernate/src/NHibernate/ConnectionReleaseMode.cs 2009-07-01 16:31:18 UTC (rev 4551)
@@ -1,3 +1,5 @@
+using System;
+
namespace NHibernate
{
public enum ConnectionReleaseMode
@@ -5,7 +7,38 @@
AfterStatement,
AfterTransaction,
OnClose
+ }
- // Parse method moved to SettingsFactory
+ public static class ConnectionReleaseModeParser
+ {
+ public static ConnectionReleaseMode Convert(string value)
+ {
+ switch (value)
+ {
+ case "after_statement":
+ throw new HibernateException("aggressive connection release (after_statement) not supported by NHibernate");
+ case "after_transaction":
+ return ConnectionReleaseMode.AfterTransaction;
+ case "on_close":
+ return ConnectionReleaseMode.OnClose;
+ default:
+ throw new HibernateException("could not determine appropriate connection release mode [" + value + "]");
+ }
+ }
+
+ public static string ToString(ConnectionReleaseMode value)
+ {
+ switch (value)
+ {
+ case ConnectionReleaseMode.AfterStatement:
+ return "after_statement";
+ case ConnectionReleaseMode.AfterTransaction:
+ return "after_transaction" ;
+ case ConnectionReleaseMode.OnClose:
+ return "on_close";
+ default:
+ throw new ArgumentOutOfRangeException("value");
+ }
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-01 13:46:24 UTC (rev 4550)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-01 16:31:18 UTC (rev 4551)
@@ -460,6 +460,7 @@
<Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" />
<Compile Include="Cache\FakeCache.cs" />
<Compile Include="Cfg\Loquacious\ConfigurationExtensions.cs" />
+ <Compile Include="Cfg\Loquacious\FluentSessionFactoryConfiguration.cs" />
<Compile Include="Cfg\Loquacious\IBatcherConfiguration.cs" />
<Compile Include="Cfg\Loquacious\ICacheConfiguration.cs" />
<Compile Include="Cfg\Loquacious\ICollectionFactoryConfiguration.cs" />
Modified: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-07-01 13:46:24 UTC (rev 4550)
+++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-07-01 16:31:18 UTC (rev 4551)
@@ -10,12 +10,15 @@
using NHibernate.Exceptions;
using NHibernate.Hql.Classic;
using NHibernate.Type;
+using NUnit.Framework;
namespace NHibernate.Test.CfgTest.Loquacious
{
+ [TestFixture]
public class ConfigurationFixture
{
- public void ProofOfConcept()
+ [Test]
+ public void CompleteConfiguration()
{
// Here I'm configuring near all properties outside the scope of Configuration class
// Using the Configuration class the user can add mappings and configure listeners
@@ -42,27 +45,67 @@
.AutoQuoteKeywords()
.BatchingQueries
.Through<SqlClientBatchingBatcherFactory>()
- .Each(10)
+ .Each(15)
.Connected
.Through<DebugConnectionProvider>()
.By<SqlClientDriver>()
.Releasing(ConnectionReleaseMode.AfterTransaction)
.With(IsolationLevel.ReadCommitted)
- .Using("The connection string but it has some overload")
+ .Using("The connection string")
.CreateCommands
.AutoCommentingSql()
.ConvertingExceptionsThrough<SQLStateConverter>()
.Preparing()
.WithTimeout(10)
- .WithMaximumDepthOfOuterJoinFetching(10)
+ .WithMaximumDepthOfOuterJoinFetching(11)
.WithHqlToSqlSubstitutions("true 1, false 0, yes 'Y', no 'N'")
.Schema
.Validating()
;
+ Assert.That(cfg.Properties[Environment.SessionFactoryName], Is.EqualTo("SomeName"));
+ Assert.That(cfg.Properties[Environment.CacheProvider],
+ Is.EqualTo(typeof(HashtableCacheProvider).AssemblyQualifiedName));
+ Assert.That(cfg.Properties[Environment.CacheRegionPrefix], Is.EqualTo("xyz"));
+ Assert.That(cfg.Properties[Environment.QueryCacheFactory],
+ Is.EqualTo(typeof(StandardQueryCache).AssemblyQualifiedName));
+ Assert.That(cfg.Properties[Environment.UseMinimalPuts], Is.EqualTo("true"));
+ Assert.That(cfg.Properties[Environment.CacheDefaultExpiration], Is.EqualTo("15"));
+ Assert.That(cfg.Properties[Environment.CollectionTypeFactoryClass],
+ Is.EqualTo(typeof(DefaultCollectionTypeFactory).AssemblyQualifiedName));
+ Assert.That(cfg.Properties[Environment.UseProxyValidator], Is.EqualTo("false"));
+ Assert.That(cfg.Properties[Environment.ProxyFactoryFactoryClass],
+ Is.EqualTo(typeof(ProxyFactoryFactory).AssemblyQualifiedName));
+ Assert.That(cfg.Properties[Environment.QueryTranslator],
+ Is.EqualTo(typeof(ClassicQueryTranslatorFactory).AssemblyQualifiedName));
+ Assert.That(cfg.Properties[Environment.DefaultCatalog], Is.EqualTo("MyCatalog"));
+ Assert.That(cfg.Properties[Environment.DefaultSchema], Is.EqualTo("MySche"));
+ Assert.That(cfg.Properties[Environment.Dialect],
+ Is.EqualTo(typeof(MsSql2000Dialect).AssemblyQualifiedName));
+ Assert.That(cfg.Properties[Environment.Hbm2ddlKeyWords], Is.EqualTo("auto-quote"));
+ Assert.That(cfg.Properties[Environment.BatchStrategy],
+ Is.EqualTo(typeof(SqlClientBatchingBatcherFactory).AssemblyQualifiedName));
+ Assert.That(cfg.Properties[Environment.BatchSize], Is.EqualTo("15"));
+ Assert.That(cfg.Properties[Environment.ConnectionProvider],
+ Is.EqualTo(typeof(DebugConnectionProvider).AssemblyQualifiedName));
+ Assert.That(cfg.Properties[Environment.ConnectionDriver],
+ Is.EqualTo(typeof(SqlClientDriver).AssemblyQualifiedName));
+ Assert.That(cfg.Properties[Environment.ReleaseConnections],
+ Is.EqualTo(ConnectionReleaseModeParser.ToString(ConnectionReleaseMode.AfterTransaction)));
+ Assert.That(cfg.Properties[Environment.Isolation], Is.EqualTo("ReadCommitted"));
+ Assert.That(cfg.Properties[Environment.ConnectionString], Is.EqualTo("The connection string"));
+ Assert.That(cfg.Properties[Environment.UseSqlComments], Is.EqualTo("true"));
+ Assert.That(cfg.Properties[Environment.SqlExceptionConverter],
+ Is.EqualTo(typeof(SQLStateConverter).AssemblyQualifiedName));
+ Assert.That(cfg.Properties[Environment.PrepareSql], Is.EqualTo("true"));
+ Assert.That(cfg.Properties[Environment.CommandTimeout], Is.EqualTo("10"));
+ Assert.That(cfg.Properties[Environment.MaxFetchDepth], Is.EqualTo("11"));
+ Assert.That(cfg.Properties[Environment.QuerySubstitutions], Is.EqualTo("true 1, false 0, yes 'Y', no 'N'"));
+ Assert.That(cfg.Properties[Environment.Hbm2ddlAuto], Is.EqualTo("validate"));
}
- public void ProofOfConceptMinimalConfiguration()
+ [Test]
+ public void UseDbConfigurationStringBuilder()
{
// This is a possible minimal configuration
// in this case we must define best default properties for each dialect
@@ -79,6 +122,13 @@
InitialCatalog = "nhibernate",
IntegratedSecurity = true
});
+
+ Assert.That(cfg.Properties[Environment.ProxyFactoryFactoryClass],
+ Is.EqualTo(typeof (ProxyFactoryFactory).AssemblyQualifiedName));
+ Assert.That(cfg.Properties[Environment.Dialect],
+ Is.EqualTo(typeof(MsSql2005Dialect).AssemblyQualifiedName));
+ Assert.That(cfg.Properties[Environment.ConnectionString],
+ Is.EqualTo("Data Source=(local);Initial Catalog=nhibernate;Integrated Security=True"));
}
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|