Ejemplo n.º 1
0
        public void Build_SortsByLastNameWithNulls()
        {
            var ranger  = new TestAgeRanger();
            var builder = new PeopleListBuilder(ranger);
            var list    = GetListWithItemsContainingNulls();
            var people  = builder.Build(list, 0, 22, 2, "asc", string.Empty);

            Assert.AreEqual(22, people.Count, "list contains 22 items");
            Assert.AreEqual(100, people[0].Id, "should sort by last name");
        }
Ejemplo n.º 2
0
        public void Build_SortsByAgeRange()
        {
            var ranger  = new TestAgeRanger();
            var builder = new PeopleListBuilder(ranger);
            var list    = GetList();
            var people  = builder.Build(list, 0, 20, 3, "asc", string.Empty);

            Assert.AreEqual(20, people.Count, "list contains 20 items");
            Assert.AreEqual("Lizzette", people[0].FirstName, "should sort by column 2");
        }
Ejemplo n.º 3
0
        public void Build_SortsByNameDescending()
        {
            var ranger  = new TestAgeRanger();
            var builder = new PeopleListBuilder(ranger);
            var list    = GetList();
            var people  = builder.Build(list, 0, 20, 1, "desc", string.Empty);

            Assert.AreEqual(20, people.Count, "list contains 20 items");
            Assert.AreEqual("Temple", people[0].FirstName, "should sort by name");
        }
Ejemplo n.º 4
0
        public void Build_SortsByLastName()
        {
            var ranger  = new TestAgeRanger();
            var builder = new PeopleListBuilder(ranger);
            var list    = GetList();
            var people  = builder.Build(list, 0, 20, 2, "asc", string.Empty);

            Assert.AreEqual(20, people.Count, "list contains 20 items");
            Assert.AreEqual("Bonds", people[0].LastName, "should sort by last name");
        }
Ejemplo n.º 5
0
        public void Build_SearchByFirstAndLastNameWithNulls()
        {
            var ranger  = new TestAgeRanger();
            var builder = new PeopleListBuilder(ranger);
            var list    = GetListWithItemsContainingNulls();
            var people  = builder.Build(list, 0, 20, 0, "asc", "AN");

            Assert.AreEqual(5, people.Count, "list contains 5 items");
            Assert.AreEqual(7, people[0].Id, "should filter output");
        }
Ejemplo n.º 6
0
        public void Build_SkipsAndTakesNRecords()
        {
            var ranger  = new TestAgeRanger();
            var builder = new PeopleListBuilder(ranger);
            var list    = GetList();
            var people  = builder.Build(list, 10, 5, 0, "asc", string.Empty);

            Assert.AreEqual(5, people.Count, "list contains 5 items");
            Assert.AreEqual("Beth", people[0].FirstName, "should sort by column 2");
        }
Ejemplo n.º 7
0
        public void Build_TakesAllRecords()
        {
            var ranger  = new TestAgeRanger();
            var builder = new PeopleListBuilder(ranger);
            var list    = GetList();
            var people  = builder.Build(list, 0, -1, 0, "asc", string.Empty);

            Assert.AreEqual(20, people.Count, "list contains All items");
            Assert.AreEqual("Scottie", people[0].FirstName, "should sort by column 2");
        }
Ejemplo n.º 8
0
        public void Build_UnsortedList()
        {
            var ranger  = new TestAgeRanger();
            var builder = new PeopleListBuilder(ranger);
            var list    = GetList();
            var people  = builder.Build(list, 0, 20, 0, "desc", string.Empty);

            Assert.AreEqual(20, people.Count, "list contains 20 items");
            Assert.AreEqual("Scottie", people[0].FirstName, "should sort by clumn 0");
        }
Ejemplo n.º 9
0
        // GET: api/People/GetPeople
        public dynamic GetPeople(
            int sEcho,
            int iDisplayStart,
            int iDisplayLength,
            string sSearch,
            int iSortCol_0,
            string sSortDir_0)
        {
            var builder = new PeopleListBuilder(_ranger);
            var list    = db.People.ToList();
            var models  = builder.Build(list, iDisplayStart, iDisplayLength, iSortCol_0, sSortDir_0, sSearch);

            return(new
            {
                recordsTotal = list.Count,
                recordsFiltered = list.Count,
                aaData = models.ToArray()
            });
        }