public void HasPages()
        {
            string hql = "from Foo where Name = 'N1'";
            PaginableRowsCounterQuery<Foo> pag =
                new PaginableRowsCounterQuery<Foo>(LastOpenedSession, new DetachedQuery(hql));
            Paginator<Foo> ptor = new Paginator<Foo>(3, pag);

            Assert.AreEqual(true, ptor.HasPages);
            Assert.AreEqual(1, ptor.RowsCount);
            Assert.AreEqual(false, ptor.HasPrevious);
            Assert.AreEqual(false, ptor.HasNext);

            IList<Foo> lpage = ptor.GetPage(1);
            Assert.AreEqual(1, lpage.Count);
        }
        public void HasNotPages()
        {
            string hql = "from Foo where Name = '-N123'";
            PaginableRowsCounterQuery<Foo> pag =
                new PaginableRowsCounterQuery<Foo>(LastOpenedSession, new DetachedQuery(hql));
            Paginator<Foo> ptor = new Paginator<Foo>(3, pag);

            Assert.AreEqual(false, ptor.HasPages);
            Assert.AreEqual(false, ptor.HasPrevious);
            Assert.AreEqual(false, ptor.HasNext);
            Assert.AreEqual(0, ptor.RowsCount.Value);

            //throw ArgumentOutOfRangeException
            IList<Foo> lpage = ptor.GetPage(1);
        }
        public void WithSelfCounter()
        {
            DetachedQuery dq = new DetachedQuery("from Foo f where f.Name like :p1");
            dq.SetString("p1", "%1_");
            IPaginable<Foo> fp = new PaginableRowsCounterQuery<Foo>(LastOpenedSession, dq);

            Paginator<Foo> ptor = new Paginator<Foo>(2, fp);
            Assert.IsTrue(ptor.AutoCalcPages);
            Assert.AreEqual(3, ptor.LastPageNumber);
            // check page 2
            IList<Foo> lpage = ptor.GetPage(2);
            Assert.AreEqual(2, lpage.Count);
            Assert.AreEqual(2, ptor.CurrentPageNumber);
            Assert.AreEqual("N12", lpage[0].Name);
            Assert.AreEqual("N13", lpage[1].Name);
        }
 public void PaginableRowsCount()
 {
     DetachedQuery dq = new DetachedQuery("from Foo f where f.Name like :p1");
     dq.SetString("p1", "N_");
     using (ISession s = OpenSession())
     {
         IPaginable<Foo> fp = new PaginableRowsCounterQuery<Foo>(LastOpenedSession, dq);
         IList<Foo> l = fp.GetPage(5, 1);
         Assert.AreEqual(5, l.Count);
         Assert.AreEqual(10, ((IRowsCounter) fp).GetRowsCount(s));
     }
 }