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 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 DefaultOptimizerBasedOnIncrementBackedByTable()
		{
			IDictionary<string, string> props = new Dictionary<string, string>();
			props[SequenceStyleGenerator.IncrementParam] = "10";
			Dialect.Dialect dialect = new TableDialect();
			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.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));
		}
		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));
		}