public void HiLoOptimizerUsedWithExplicitInitialValueUsesPooledSequenceGenerator() { Dialect.Dialect dialect = new PooledSequenceDialect(); var props = new Dictionary <string, string>(); props[SequenceStyleGenerator.OptimizerParam] = OptimizerFactory.HiLo; props[SequenceStyleGenerator.InitialParam] = "20"; var generator = new SequenceStyleGenerator(); generator.Configure(NHibernateUtil.Int64, props, dialect); Assert.That(generator.DatabaseStructure, Is.AssignableFrom(typeof(SequenceStructure))); Assert.That(generator.Optimizer, Is.AssignableFrom(typeof(OptimizerFactory.HiLoOptimizer))); //Assert.That(generator.SqlCreateStrings(dialect).Length, Is.EqualTo(3)); Assert.That(generator.SqlCreateStrings(dialect), Is.EqualTo(PoolSequenceString)); }
public void PreferPooledLoSettingHonored() { var dialect = new PooledSequenceDialect(); var props = new Dictionary <string, string>(); props[SequenceStyleGenerator.IncrementParam] = "20"; var generator = new SequenceStyleGenerator(); generator.Configure(NHibernateUtil.Int64, props, dialect); Assert.That(generator.DatabaseStructure, Is.AssignableFrom(typeof(SequenceStructure))); Assert.That(generator.Optimizer, Is.AssignableFrom(typeof(OptimizerFactory.PooledOptimizer))); props[Cfg.Environment.PreferPooledValuesLo] = "true"; generator = new SequenceStyleGenerator(); generator.Configure(NHibernateUtil.Int64, props, dialect); Assert.That(generator.DatabaseStructure, Is.AssignableFrom(typeof(SequenceStructure))); Assert.That(generator.Optimizer, Is.AssignableFrom(typeof(OptimizerFactory.PooledLoOptimizer))); }
public void DefaultOptimizerBasedOnIncrementBackedBySequence() { var props = new Dictionary <string, string>(); props[SequenceStyleGenerator.IncrementParam] = "10"; // for dialects which do not support pooled sequences, we default to pooled+table var dialect = new SequenceDialect(); var generator = new SequenceStyleGenerator(); generator.Configure(NHibernateUtil.Int64, props, dialect); Assert.That(generator.DatabaseStructure, Is.AssignableFrom(typeof(TableStructure))); Assert.That(generator.Optimizer, Is.AssignableFrom(typeof(OptimizerFactory.PooledOptimizer))); Assert.That(generator.DatabaseStructure.Name, Is.EqualTo(SequenceStyleGenerator.DefaultSequenceName)); // for dialects which do support pooled sequences, we default to pooled+sequence dialect = new PooledSequenceDialect(); generator = new SequenceStyleGenerator(); generator.Configure(NHibernateUtil.Int64, props, dialect); Assert.That(generator.DatabaseStructure, Is.AssignableFrom(typeof(SequenceStructure))); Assert.That(generator.Optimizer, Is.AssignableFrom(typeof(OptimizerFactory.PooledOptimizer))); Assert.That(generator.DatabaseStructure.Name, Is.EqualTo(SequenceStyleGenerator.DefaultSequenceName)); }
public void DefaultOptimizerBasedOnIncrementBackedBySequence() { IDictionary<string, string> props = new Dictionary<string, string>(); props[SequenceStyleGenerator.IncrementParam] = "10"; // for dialects which do not support pooled sequences, we default to hilo Dialect.Dialect dialect = new SequenceDialect(); SequenceStyleGenerator generator = new SequenceStyleGenerator(); generator.Configure(NHibernateUtil.Int64, props, dialect); Assert.That(generator.DatabaseStructure, Is.AssignableFrom(typeof (SequenceStructure))); Assert.That(generator.Optimizer, Is.AssignableFrom(typeof (OptimizerFactory.HiLoOptimizer))); Assert.That(generator.DatabaseStructure.Name, Is.EqualTo(SequenceStyleGenerator.DefaultSequenceName)); // for dialects which do support pooled sequences, we default to pooled dialect = new PooledSequenceDialect(); generator = new SequenceStyleGenerator(); generator.Configure(NHibernateUtil.Int64, props, dialect); Assert.That(generator.DatabaseStructure, Is.AssignableFrom(typeof (SequenceStructure))); Assert.That(generator.Optimizer, Is.AssignableFrom(typeof (OptimizerFactory.PooledOptimizer))); Assert.That(generator.DatabaseStructure.Name, Is.EqualTo(SequenceStyleGenerator.DefaultSequenceName)); }
public void PreferPooledLoSettingHonored() { Dialect.Dialect dialect = new PooledSequenceDialect(); IDictionary<string, string> props = new Dictionary<string, string>(); props[SequenceStyleGenerator.IncrementParam] = "20"; SequenceStyleGenerator generator = new SequenceStyleGenerator(); generator.Configure(NHibernateUtil.Int64, props, dialect); Assert.That(generator.DatabaseStructure, Is.AssignableFrom(typeof(SequenceStructure))); Assert.That(generator.Optimizer, Is.AssignableFrom(typeof(OptimizerFactory.PooledOptimizer))); props[NHibernate.Cfg.Environment.PreferPooledValuesLo] = "true"; generator = new SequenceStyleGenerator(); generator.Configure(NHibernateUtil.Int64, props, dialect); Assert.That(generator.DatabaseStructure, Is.AssignableFrom(typeof(SequenceStructure))); Assert.That(generator.Optimizer, Is.AssignableFrom(typeof(OptimizerFactory.PooledLoOptimizer))); }
public void PoolOptimizerUsedWithExplicitIncrementAndInitialValueOfOneUsesNonPooledSequenceGenerator() { Dialect.Dialect dialect = new PooledSequenceDialect(); var props = new Dictionary<string, string>(); props[SequenceStyleGenerator.OptimizerParam] = OptimizerFactory.Pool; props[SequenceStyleGenerator.InitialParam] = "1"; props[SequenceStyleGenerator.IncrementParam] = "1"; var generator = new SequenceStyleGenerator(); generator.Configure(NHibernateUtil.Int64, props, dialect); Assert.That(generator.DatabaseStructure, Is.AssignableFrom(typeof(SequenceStructure))); Assert.That(generator.Optimizer, Is.AssignableFrom(typeof(OptimizerFactory.PooledOptimizer))); //Assert.That(generator.SqlCreateStrings(dialect).Length, Is.EqualTo(1)); Assert.That(generator.SqlCreateStrings(dialect), Is.EqualTo(SequenceString)); }