public void LocalSessionFactoryObjectWithDbProviderAndProperties() { IDbProvider dbProvider = DbProviderFactory.GetDbProvider("System.Data.SqlClient"); dbProvider.ConnectionString = "Data Source=(local);Database=Spring;Trusted_Connection=false"; LocalSessionFactoryObject sfo = new LocalSessionFactoryObject(); sfo.DbProvider = dbProvider; sfo.ApplicationContext = new StaticApplicationContext(); IDictionary properties = new Hashtable(); properties.Add(Environment.Dialect, typeof(MsSql2000Dialect).AssemblyQualifiedName); properties.Add(Environment.ConnectionDriver, typeof(SqlClientDriver).AssemblyQualifiedName); properties.Add(Environment.ConnectionProvider, typeof(DriverConnectionProvider).AssemblyQualifiedName); #if NH_2_1 // since 2.1. "hbm2ddl.keywords = 'keywords'" is the default which causes the SessionFactory to connect to the db upon creation // we don't want this in this unit test properties.Add(Environment.Hbm2ddlKeyWords, "none"); #endif sfo.HibernateProperties = properties; sfo.AfterPropertiesSet(); Assert.IsNotNull(sfo.Configuration); Assert.AreEqual(sfo.Configuration.Properties[Environment.ConnectionProvider], typeof(DriverConnectionProvider).AssemblyQualifiedName); Assert.AreEqual(sfo.Configuration.Properties[Environment.ConnectionDriver], typeof(SqlClientDriver).AssemblyQualifiedName); Assert.AreEqual(sfo.Configuration.Properties[Environment.Dialect], typeof(MsSql2000Dialect).AssemblyQualifiedName); #if NH_2_1 Assert.AreEqual(sfo.Configuration.Properties[Environment.ProxyFactoryFactoryClass], typeof(ProxyFactoryFactory).AssemblyQualifiedName); // Spring's IBytecodeProvider should be the default // Assert.AreEqual(typeof(BytecodeProvider), Environment.BytecodeProvider.GetType(), "default IBytecodeProvider was not Spring's BytecodeProvider"); #endif }
public void LocalSessionFactoryObjectWithInvalidMapping() { LocalSessionFactoryObject sfo = new LocalSessionFactoryObject(); sfo.MappingResources = new string[] { "mapping.hbm.xml" }; sfo.AfterPropertiesSet(); }
public void LocalSessionFactoryObjectWithInvalidMapping() { LocalSessionFactoryObject sfo = new LocalSessionFactoryObject(); sfo.MappingResources = new string[] { "mapping.hbm.xml"}; sfo.AfterPropertiesSet(); }
public void LocalSessionFactoryObjectWithInvalidMapping() { LocalSessionFactoryObject sfo = new LocalSessionFactoryObject(); sfo.MappingResources = new string[] { "mapping.hbm.xml" }; Assert.Throws<FileNotFoundException>(() => sfo.AfterPropertiesSet()); }
public void LocalSessionFactoryObjectWithDbProviderAndProperties() { IDbProvider dbProvider = DbProviderFactory.GetDbProvider("System.Data.SqlClient"); dbProvider.ConnectionString = "Data Source=(local);Database=Spring;Trusted_Connection=false"; LocalSessionFactoryObject sfo = new LocalSessionFactoryObject(); sfo.DbProvider = dbProvider; sfo.ApplicationContext = new StaticApplicationContext(); Dictionary<string, string> properties = new Dictionary<string, string>(); properties.Add(Environment.Dialect, typeof(MsSql2000Dialect).AssemblyQualifiedName); properties.Add(Environment.ConnectionDriver, typeof(SqlClientDriver).AssemblyQualifiedName); properties.Add(Environment.ConnectionProvider, typeof(DriverConnectionProvider).AssemblyQualifiedName); // since 2.1. "hbm2ddl.keywords = 'keywords'" is the default which causes the SessionFactory to connect to the db upon creation // we don't want this in this unit test properties.Add(Environment.Hbm2ddlKeyWords, "none"); sfo.HibernateProperties = properties; sfo.AfterPropertiesSet(); Assert.IsNotNull(sfo.Configuration); Assert.AreEqual(sfo.Configuration.Properties[Environment.ConnectionProvider], typeof(DriverConnectionProvider).AssemblyQualifiedName); Assert.AreEqual(sfo.Configuration.Properties[Environment.ConnectionDriver], typeof(SqlClientDriver).AssemblyQualifiedName); Assert.AreEqual(sfo.Configuration.Properties[Environment.Dialect], typeof(MsSql2000Dialect).AssemblyQualifiedName); Assert.Throws<KeyNotFoundException>(() => { var x = sfo.Configuration.Properties[Environment.ProxyFactoryFactoryClass]; }, "ProxyFactoryFactory should not be explicitly set!"); Assert.AreNotEqual(typeof(BytecodeProvider), Environment.BytecodeProvider.GetType(), "default IBytecodeProvider should not be Spring's BytecodeProvider!"); }
public void LocalSessionFactoryObjectWithInvalidMapping() { LocalSessionFactoryObject sfo = new LocalSessionFactoryObject(); sfo.MappingResources = new string[] { "mapping.hbm.xml" }; Assert.Throws <FileNotFoundException>(() => sfo.AfterPropertiesSet()); }
public void LocalSessionFactoryObjectWithDbProviderAndProperties() { IDbProvider dbProvider = DbProviderFactory.GetDbProvider("System.Data.SqlClient"); dbProvider.ConnectionString = "Data Source=(local);Database=Spring;Trusted_Connection=false"; LocalSessionFactoryObject sfo = new LocalSessionFactoryObject(); sfo.DbProvider = dbProvider; sfo.ApplicationContext = new StaticApplicationContext(); Dictionary <string, string> properties = new Dictionary <string, string>(); properties.Add(Environment.Dialect, typeof(MsSql2000Dialect).AssemblyQualifiedName); properties.Add(Environment.ConnectionDriver, typeof(SqlClientDriver).AssemblyQualifiedName); properties.Add(Environment.ConnectionProvider, typeof(DriverConnectionProvider).AssemblyQualifiedName); // since 2.1. "hbm2ddl.keywords = 'keywords'" is the default which causes the SessionFactory to connect to the db upon creation // we don't want this in this unit test properties.Add(Environment.Hbm2ddlKeyWords, "none"); sfo.HibernateProperties = properties; sfo.AfterPropertiesSet(); Assert.IsNotNull(sfo.Configuration); Assert.AreEqual(sfo.Configuration.Properties[Environment.ConnectionProvider], typeof(DriverConnectionProvider).AssemblyQualifiedName); Assert.AreEqual(sfo.Configuration.Properties[Environment.ConnectionDriver], typeof(SqlClientDriver).AssemblyQualifiedName); Assert.AreEqual(sfo.Configuration.Properties[Environment.Dialect], typeof(MsSql2000Dialect).AssemblyQualifiedName); Assert.Throws <KeyNotFoundException>(() => { var x = sfo.Configuration.Properties[Environment.ProxyFactoryFactoryClass]; }, "ProxyFactoryFactory should not be explicitly set!"); Assert.AreNotEqual(typeof(BytecodeProvider), Environment.BytecodeProvider.GetType(), "default IBytecodeProvider should not be Spring's BytecodeProvider!"); }
public void LocalSessionFactoryObjectWithInvalidProperties() { LocalSessionFactoryObject sfo = new LocalSessionFactoryObject(); IDictionary properties = new Hashtable(); properties.Add(Environment.Dialect, typeof(MsSql2000Dialect).AssemblyQualifiedName); properties.Add(Environment.ConnectionProvider, "myClass"); sfo.HibernateProperties = properties; sfo.AfterPropertiesSet(); }
public void LocalSessionFactoryObjectWithInvalidProperties() { LocalSessionFactoryObject sfo = new LocalSessionFactoryObject(); Dictionary <string, string> properties = new Dictionary <string, string>(); properties.Add(Environment.Dialect, typeof(MsSql2000Dialect).AssemblyQualifiedName); properties.Add(Environment.ConnectionProvider, "myClass"); sfo.HibernateProperties = properties; Assert.Throws <HibernateException>(() => sfo.AfterPropertiesSet()); }
public void LocalSessionFactoryObjectWithInvalidProperties() { LocalSessionFactoryObject sfo = new LocalSessionFactoryObject(); Dictionary<string, string> properties = new Dictionary<string, string>(); properties.Add(Environment.Dialect, typeof(MsSql2000Dialect).AssemblyQualifiedName); properties.Add(Environment.ConnectionProvider, "myClass"); sfo.HibernateProperties = properties; Assert.Throws<HibernateException>(() => sfo.AfterPropertiesSet()); }