Esempio n. 1
0
        public void TestEnumerators_NoPaging()
        {
            PagedDataSource ds = new PagedDataSource();

            ds.AllowPaging = false;

            //
            // Collection Enumerator
            //
            Queue q = new Queue();

            for (int i = 0; i < 50; i++)
            {
                q.Enqueue(i);
            }
            ds.DataSource = q;
            EnumeratorTester_NoPaging(ds.GetEnumerator(), "collection");

            //
            // List Enumerator
            //
            ArrayList l = new ArrayList();

            for (int i = 0; i < 50; i++)
            {
                l.Add(i);
            }
            EnumeratorTester_NoPaging(ds.GetEnumerator(), "list");
        }
Esempio n. 2
0
        public void TestEnumerators()
        {
            PagedDataSource ds = new PagedDataSource();

            ds.AllowPaging      = true;
            ds.PageSize         = 10;
            ds.CurrentPageIndex = 2;


            //
            // Collection Enumerator
            //
            Queue q = new Queue();

            for (int i = 0; i < 50; i++)
            {
                q.Enqueue(i);
            }
            ds.DataSource = q;
            EnumeratorTester(ds.GetEnumerator(), "collection");

            //
            // List Enumerator
            //
            ArrayList l = new ArrayList();

            for (int i = 0; i < 50; i++)
            {
                l.Add(i);
            }
            EnumeratorTester(ds.GetEnumerator(), "list");
        }
Esempio n. 3
0
        public void NullSource()
        {
            PagedDataSource ds = new PagedDataSource();

            ds.DataSource = null;
            IEnumerator data = ds.GetEnumerator();
        }
Esempio n. 4
0
        public void Paging3()
        {
            PagedDataSource paged = new PagedDataSource();

            paged.AllowPaging = true;
            paged.PageSize    = 5;
            DataTable table = new DataTable();

            FillTable(table, 100);
            paged.DataSource = new DataView(table);

            paged.CurrentPageIndex = -7;
            Assert.AreEqual(-7, paged.CurrentPageIndex, "current");
            Assert.IsFalse(paged.IsFirstPage, "first");
            Assert.IsFalse(paged.IsLastPage, "last");
            IEnumerator rator = paged.GetEnumerator();

            Assert.AreEqual(-7, paged.CurrentPageIndex, "current-2");
            Assert.IsTrue(rator.MoveNext(), "beyondtheend");
            DataRowView drv = (DataRowView)rator.Current; // Throws (out of range)
        }
Esempio n. 5
0
        public void Paging1()
        {
            PagedDataSource paged = new PagedDataSource();

            paged.AllowPaging = true;
            paged.PageSize    = 5;
            DataTable table = new DataTable();

            FillTable(table, 100);
            paged.DataSource = new DataView(table);

            Assert.IsTrue(paged.IsFirstPage, "first-1");
            Assert.IsFalse(paged.IsLastPage, "last-1");

            paged.CurrentPageIndex = 100; // no problem setting this.
            Assert.AreEqual(100, paged.CurrentPageIndex, "current-1");
            Assert.IsFalse(paged.IsFirstPage, "first-2");
            Assert.IsFalse(paged.IsLastPage, "last-2");
            IEnumerator rator = paged.GetEnumerator();

            Assert.IsFalse(rator.MoveNext(), "beyondtheend-1");
        }
Esempio n. 6
0
        public void VirtualPager1()
        {
            PagedDataSource paged = new PagedDataSource();

            paged.AllowPaging  = true;
            paged.PageSize     = 20;
            paged.VirtualCount = 100;
            DataTable table = new DataTable();

            FillTable(table, 100);
            paged.DataSource = new DataView(table);

            int         count = 0;
            IEnumerator rator = paged.GetEnumerator();

            while (rator.MoveNext())
            {
                count++;
            }
            Assert.AreEqual(20, count, "count");
            Assert.AreEqual(true, paged.IsFirstPage, "first");
            Assert.AreEqual(false, paged.IsLastPage, "last");
        }
Esempio n. 7
0
        public void Paging4()
        {
            PagedDataSource paged = new PagedDataSource();

            paged.AllowPaging = true;
            paged.PageSize    = 5;
            DataTable table = new DataTable();

            FillTable(table, 100);
            paged.DataSource = new DataView(table);

            paged.CurrentPageIndex = 1;
            IEnumerator rator = paged.GetEnumerator();

            Assert.IsTrue(rator.MoveNext(), "beginning-1");
            DataRowView drv = (DataRowView)rator.Current;
            int         one = Int32.Parse((string)drv ["one"]);

            Assert.IsTrue(one == 0 || one == 1, "one-1");
            int res = one + 2 * Int32.Parse((string)drv ["two"]);

            Assert.AreEqual(5, res, "five");
        }