public void DefaultedSequenceBackedConfiguration() { var dialect = new SequenceDialect(); var props = new Dictionary <string, string>(); 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.NoopOptimizer))); Assert.That(generator.DatabaseStructure.Name, Is.EqualTo(SequenceStyleGenerator.DefaultSequenceName)); }
public void ForceTableUse() { Dialect.Dialect dialect = new SequenceDialect(); IDictionary <string, string> props = new Dictionary <string, string>(); props[SequenceStyleGenerator.ForceTableParam] = "true"; SequenceStyleGenerator 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.NoopOptimizer))); Assert.That(generator.DatabaseStructure.Name, Is.EqualTo(SequenceStyleGenerator.DefaultSequenceName)); }
public void ExplicitOptimizerWithExplicitIncrementSize() { var dialect = new SequenceDialect(); // optimizer=none w/ increment > 1 => should honor optimizer var props = new Dictionary <string, string>(); props[SequenceStyleGenerator.OptimizerParam] = OptimizerFactory.None; 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.NoopOptimizer))); Assert.That(generator.Optimizer.IncrementSize, Is.EqualTo(1)); Assert.That(generator.DatabaseStructure.IncrementSize, Is.EqualTo(1)); // optimizer=hilo w/ increment > 1 => hilo props = new Dictionary <string, string>(); props[SequenceStyleGenerator.OptimizerParam] = OptimizerFactory.HiLo; props[SequenceStyleGenerator.IncrementParam] = "20"; 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.Optimizer.IncrementSize, Is.EqualTo(20)); Assert.That(generator.DatabaseStructure.IncrementSize, Is.EqualTo(20)); // optimizer=pooled w/ increment > 1 => pooled+table props = new Dictionary <string, string>(); props[SequenceStyleGenerator.OptimizerParam] = OptimizerFactory.Pool; props[SequenceStyleGenerator.IncrementParam] = "20"; generator = new SequenceStyleGenerator(); generator.Configure(NHibernateUtil.Int64, props, dialect); // because the dialect reports that it does not support pooled sequences, the expectation is that we will // use a table for the backing structure... Assert.That(generator.DatabaseStructure, Is.AssignableFrom(typeof(TableStructure))); Assert.That(generator.Optimizer, Is.AssignableFrom(typeof(OptimizerFactory.PooledOptimizer))); Assert.That(generator.Optimizer.IncrementSize, Is.EqualTo(20)); Assert.That(generator.DatabaseStructure.IncrementSize, Is.EqualTo(20)); }
public void ExplicitOptimizerWithExplicitIncrementSize() { // with sequence ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Dialect.Dialect dialect = new SequenceDialect(); // optimizer=none w/ increment > 1 => should honor optimizer IDictionary<string, string> props = new Dictionary<string, string>(); props[SequenceStyleGenerator.OptimizerParam] = OptimizerFactory.None; 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.NoopOptimizer))); Assert.AreEqual(1, generator.Optimizer.IncrementSize); Assert.AreEqual(1, generator.DatabaseStructure.IncrementSize); // optimizer=hilo w/ increment > 1 => hilo props = new Dictionary<string, string>(); props[SequenceStyleGenerator.OptimizerParam] = OptimizerFactory.HiLo; props[SequenceStyleGenerator.IncrementParam] = "20"; 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.AreEqual(20, generator.Optimizer.IncrementSize); Assert.AreEqual(20, generator.DatabaseStructure.IncrementSize); // optimizer=pooled w/ increment > 1 => pooled+table props = new Dictionary<string, string>(); props[SequenceStyleGenerator.OptimizerParam] = OptimizerFactory.Pool; props[SequenceStyleGenerator.IncrementParam] = "20"; generator = new SequenceStyleGenerator(); generator.Configure(NHibernateUtil.Int64, props, dialect); // because the dialect reports that it does not support pooled sequences, the expectation is that we will // use a table for the backing structure... Assert.That(generator.DatabaseStructure, Is.AssignableFrom(typeof (TableStructure))); Assert.That(generator.Optimizer, Is.AssignableFrom(typeof (OptimizerFactory.PooledOptimizer))); Assert.AreEqual(20, generator.Optimizer.IncrementSize); Assert.AreEqual(20, generator.DatabaseStructure.IncrementSize); }
public void ExplicitOptimizerWithExplicitIncrementSize() { // with sequence ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Dialect.Dialect dialect = new SequenceDialect(); // optimizer=none w/ increment > 1 => should honor optimizer IDictionary <string, string> props = new Dictionary <string, string>(); props[SequenceStyleGenerator.OptimizerParam] = OptimizerFactory.None; 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.NoopOptimizer))); Assert.AreEqual(1, generator.Optimizer.IncrementSize); Assert.AreEqual(1, generator.DatabaseStructure.IncrementSize); // optimizer=hilo w/ increment > 1 => hilo props = new Dictionary <string, string>(); props[SequenceStyleGenerator.OptimizerParam] = OptimizerFactory.HiLo; props[SequenceStyleGenerator.IncrementParam] = "20"; 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.AreEqual(20, generator.Optimizer.IncrementSize); Assert.AreEqual(20, generator.DatabaseStructure.IncrementSize); // optimizer=pooled w/ increment > 1 => hilo props = new Dictionary <string, string>(); props[SequenceStyleGenerator.OptimizerParam] = OptimizerFactory.Pool; props[SequenceStyleGenerator.IncrementParam] = "20"; 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.AreEqual(20, generator.Optimizer.IncrementSize); Assert.AreEqual(20, generator.DatabaseStructure.IncrementSize); }
public void ExplicitOptimizerWithExplicitIncrementSize() { // with sequence ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Dialect.Dialect dialect = new SequenceDialect(); // optimizer=none w/ increment > 1 => should honor optimizer IDictionary<string, string> props = new Dictionary<string, string>(); props[SequenceStyleGenerator.OptimizerParam] = OptimizerFactory.None; 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.NoopOptimizer))); Assert.AreEqual(1, generator.Optimizer.IncrementSize); Assert.AreEqual(1, generator.DatabaseStructure.IncrementSize); // optimizer=hilo w/ increment > 1 => hilo props = new Dictionary<string, string>(); props[SequenceStyleGenerator.OptimizerParam] = OptimizerFactory.HiLo; props[SequenceStyleGenerator.IncrementParam] = "20"; 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.AreEqual(20, generator.Optimizer.IncrementSize); Assert.AreEqual(20, generator.DatabaseStructure.IncrementSize); // optimizer=pooled w/ increment > 1 => hilo props = new Dictionary<string, string>(); props[SequenceStyleGenerator.OptimizerParam] = OptimizerFactory.Pool; props[SequenceStyleGenerator.IncrementParam] = "20"; 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.AreEqual(20, generator.Optimizer.IncrementSize); Assert.AreEqual(20, generator.DatabaseStructure.IncrementSize); }
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 DefaultedSequenceBackedConfiguration() { Dialect.Dialect dialect = new SequenceDialect(); IDictionary<string, string> props = new Dictionary<string, string>(); 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.NoopOptimizer))); 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 ForceTableUse() { var dialect = new SequenceDialect(); var props = new Dictionary<string, string>(); props[SequenceStyleGenerator.ForceTableParam] = "true"; 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.NoopOptimizer))); Assert.That(generator.DatabaseStructure.Name, Is.EqualTo(SequenceStyleGenerator.DefaultSequenceName)); }