public void OverrideTest() { TestDetachedQuery origin = new TestDetachedQuery(); origin.SetMaxResults(10).SetFirstResult(5).SetCacheable(true).SetReadOnly(true).SetTimeout(444).SetFlushMode (FlushMode.Auto).SetCacheRegion("A_REGION").SetResultTransformer(new AliasToBeanResultTransformer(typeof(NoFoo))); origin.SetLockMode("LM1", LockMode.Upgrade); origin.SetProperties(new Foo("Pallino", "Pinco")); origin.SetInt64(1, 1); TestDetachedQuery tdq = new TestDetachedQuery(); tdq.SetLockMode("LM1", LockMode.Read); tdq.SetLockMode("LM2", LockMode.Write); tdq.SetProperties(new Foo("Fulano", "De Tal")); tdq.SetAnsiString(1, ""); //will be override tdq.SetByte(4, 255); tdq.SetCharacter(5, 'A'); tdq.SetDateTime(6, DateTime.MinValue); // will be override tdq.SetDateTime("6", DateTime.MinValue); // will be override tdq.SetDouble("8", 8.1f); tdq.SetEntity("9", new Foo("Fulano", "De Tal")); tdq.SetParameterList("UntypedList", new int[] { 5, 6, 7, 8 }); // will be override tdq.SetParameterList("TypedList", new Int64[] { 5, 6, 7, 8 }, NHibernateUtil.Int64); // will be override tdq.OverrideInfoFrom(origin); Assert.AreEqual(5, tdq.Selection.FirstRow); Assert.AreEqual(444, tdq.Selection.Timeout); Assert.IsTrue(tdq.Cacheable); Assert.IsTrue(tdq.ReadOnly); Assert.AreEqual(FlushMode.Auto, tdq.FlushMode); Assert.AreEqual("A_REGION", tdq.CacheRegion); Assert.IsNotNull(tdq.ResultTransformer); // override of LockModes Assert.AreEqual(1, tdq.LockModes.Count); Assert.IsTrue(tdq.LockModes.ContainsKey("LM1")); Assert.AreEqual(LockMode.Upgrade, tdq.LockModes["LM1"]); // override OptionalUntypeParams Assert.AreEqual(1, tdq.OptionalUntypeParams.Count); Assert.IsTrue(tdq.OptionalUntypeParams[0].Equals(new Foo("Pallino", "Pinco"))); // override positional parameters Assert.AreEqual(1, tdq.PosParams.Count); Assert.IsTrue(tdq.PosParams[1].Type.Equals(NHibernateUtil.Int64)); // override named parameters Assert.AreEqual(0, tdq.NamedParams.Count); // override named parameters list Assert.AreEqual(0, tdq.NamedUntypeListParams.Count); // override named params lists Assert.AreEqual(0, tdq.NamedListParams.Count); }
public void OverrideTest() { TestDetachedQuery origin = new TestDetachedQuery(); origin.SetMaxResults(10).SetFirstResult(5).SetCacheable(true).SetReadOnly(true).SetTimeout(444).SetFlushMode (FlushMode.Auto).SetCacheRegion("A_REGION").SetResultTransformer(new AliasToBeanResultTransformer(typeof(NoFoo))); origin.SetLockMode("LM1", LockMode.Upgrade); origin.SetProperties(new Foo("Pallino", "Pinco")); origin.SetInt64(1, 1); TestDetachedQuery tdq = new TestDetachedQuery(); tdq.SetLockMode("LM1", LockMode.Read); tdq.SetLockMode("LM2", LockMode.Write); tdq.SetProperties(new Foo("Fulano", "De Tal")); tdq.SetAnsiString(1, ""); //will be override tdq.SetByte(4, 255); tdq.SetCharacter(5, 'A'); tdq.SetDateTime(6, DateTime.MinValue); // will be override tdq.SetDateTime("6", DateTime.MinValue); // will be override tdq.SetDouble("8", 8.1f); tdq.SetEntity("9", new Foo("Fulano", "De Tal")); tdq.SetParameterList("UntypedList", new int[] { 5, 6, 7, 8 }); // will be override tdq.SetParameterList("TypedList", new Int64[] { 5, 6, 7, 8 }, NHibernateUtil.Int64); // will be override tdq.OverrideInfoFrom(origin); Assert.AreEqual(5, tdq.Selection.FirstRow); Assert.AreEqual(444, tdq.Selection.Timeout); Assert.IsTrue(tdq.Cacheable); Assert.IsTrue(tdq.ReadOnly); Assert.AreEqual(FlushMode.Auto, tdq.FlushMode); Assert.AreEqual("A_REGION", tdq.CacheRegion); Assert.IsNotNull(tdq.ResultTransformer); // override of LockModes Assert.AreEqual(1, tdq.LockModes.Count); Assert.IsTrue(tdq.LockModes.ContainsKey("LM1")); Assert.AreEqual(LockMode.Upgrade, tdq.LockModes["LM1"]); // override OptionalUntypeParams Assert.AreEqual(1, tdq.OptionalUntypeParams.Count); Assert.IsTrue(tdq.OptionalUntypeParams[0].Equals(new Foo("Pallino", "Pinco"))); // override positional parameters Assert.AreEqual(1, tdq.PosParams.Count); Assert.IsTrue(tdq.PosParams[1].Type.Equals(NHibernateUtil.Int64)); // override named parameters Assert.AreEqual(0, tdq.NamedParams.Count); // override named parameters list Assert.AreEqual(0, tdq.NamedUntypeListParams.Count); // override named params lists Assert.AreEqual(0, tdq.NamedListParams.Count); }