public void TransformingShouldDelayingParameterCopy() { var originalQuery = new DetachedQuery("from Foo f where f.Name like :p1"); IRowsCounter rc = QueryRowsCounter.Transforming(originalQuery); originalQuery.SetString("p1", "%1_"); SessionFactory.EncloseInTransaction(s => Assert.AreEqual(5, rc.GetRowsCount(s))); }
public void RowsCountTransforming() { DetachedQuery dq = new DetachedQuery("from Foo f where f.Name like :p1"); dq.SetString("p1", "%1_"); IRowsCounter rc = QueryRowsCounter.Transforming(dq); using (ISession s = OpenSession()) { Assert.AreEqual(5, rc.GetRowsCount(s)); } }
public void RowsCountTransforming() { Assert.Throws <ArgumentNullException>(() => QueryRowsCounter.Transforming(null)); var originalQuery = new DetachedQuery("from Foo f where f.Name like :p1"); originalQuery.SetString("p1", "%1_"); IRowsCounter rc = QueryRowsCounter.Transforming(originalQuery); SessionFactory.EncloseInTransaction(s => Assert.AreEqual(5, rc.GetRowsCount(s))); }
/// <summary> /// Create a new instance of <see cref="Paginator{T}"/>. /// </summary> /// <param name="pageSize">The page's elements quantity.</param> /// <param name="paginable">The paginable.</param> /// <param name="counter">The rows counter.</param> /// <exception cref="ArgumentNullException">If <paramref name="paginable"/> is null.</exception> /// <exception cref="ArgumentOutOfRangeException">If <paramref name="pageSize"/> equal or less than zero.</exception> /// <remarks> /// If <paramref name="counter"/> is null it is simply ignored. /// If <paramref name="counter"/> is available the paginator work with "AutoCalcPages mode" enabled. /// <para> /// The Paginator don't make any check about queries. /// This mean, for example, that the resposablity to check if the <paramref name="counter"/> query /// work according the <paramref name="paginable"/> query is by the paginator user. /// Write your tests to be sure. /// </para> /// </remarks> public Paginator(int pageSize, IPaginable <T> paginable, IRowsCounter counter) : this(pageSize, paginable) { Counter = counter; }