public void TestThatSortingByNameDescendingReturnsMattFirstAndAlexLast()
 {
     _param.SortingColumnsCount = 1;
     _param.SortingColumns = new[] {1};
     _param.SortDirections = new[] {"desc"};
     _sorter = new DatatableSorter<Person>(_param, _properties);
     List<Person> sorted = _sorter.Sort(People).ToList();
     Assert.That(sorted.First(), Is.EqualTo(Matt), "The first element should be Matt");
     Assert.That(sorted.Last(), Is.EqualTo(Alex), "The last element should be Alex");
 }
 public void TestThatSortingByBirthdayAscendingReturnsMattFirstAndAnnLast()
 {
     _param.SortingColumnsCount = 1;
     _param.SortingColumns = new[] {2};
     _param.SortDirections = new[] {"asc"};
     _sorter = new DatatableSorter<Person>(_param, _properties);
     List<Person> sorted = _sorter.Sort(People).ToList();
     Assert.That(sorted.First(), Is.EqualTo(Matt), "The first element should be Matt, he's the oldest");
     Assert.That(sorted.Last(), Is.EqualTo(Ann), "The last element should be Ann, she's the youngest");
 }
Exemple #3
0
        public void TestThatSortingDoesntAffectTheNumberOfResults()
        {
            _param.SortingColumnsCount = 1;
            _param.SortingColumns      = new[] { 1 };
            _param.SortDirections      = new[] { "asc" };
            _sorter = new DatatableSorter <Person>(_param, _properties);
            List <Person> sorted = _sorter.Sort(People).ToList();

            Assert.That(sorted.Count(), Is.EqualTo(3), "Sorting should have no effect on the number of results");
        }
Exemple #4
0
        public void TestThatSortingByNameDescendingReturnsMattFirstAndAlexLast()
        {
            _param.SortingColumnsCount = 1;
            _param.SortingColumns      = new[] { 1 };
            _param.SortDirections      = new[] { "desc" };
            _sorter = new DatatableSorter <Person>(_param, _properties);
            List <Person> sorted = _sorter.Sort(People).ToList();

            Assert.That(sorted.First(), Is.EqualTo(Matt), "The first element should be Matt");
            Assert.That(sorted.Last(), Is.EqualTo(Alex), "The last element should be Alex");
        }
Exemple #5
0
        public void TestThatSortingByBirthdayAscendingReturnsMattFirstAndAnnLast()
        {
            _param.SortingColumnsCount = 1;
            _param.SortingColumns      = new[] { 2 };
            _param.SortDirections      = new[] { "asc" };
            _sorter = new DatatableSorter <Person>(_param, _properties);
            List <Person> sorted = _sorter.Sort(People).ToList();

            Assert.That(sorted.First(), Is.EqualTo(Matt), "The first element should be Matt, he's the oldest");
            Assert.That(sorted.Last(), Is.EqualTo(Ann), "The last element should be Ann, she's the youngest");
        }
 public void TestThatSortingDoesntAffectTheNumberOfResults()
 {
     _param.SortingColumnsCount = 1;
     _param.SortingColumns = new[] {1};
     _param.SortDirections = new[] {"asc"};
     _sorter = new DatatableSorter<Person>(_param, _properties);
     List<Person> sorted = _sorter.Sort(People).ToList();
     Assert.That(sorted.Count(), Is.EqualTo(3), "Sorting should have no effect on the number of results");
 }
Exemple #7
0
        /// <summary>
        ///     Sorts the entities by the desired properties in their proper order
        /// </summary>
        /// <param name="param">
        ///     The param containing the sorting logic
        /// </param>
        /// <returns>
        ///     the sorted entities
        /// </returns>
        private IQueryable <TEntity> Sort(DatatableParam param)
        {
            var sorter = new DatatableSorter <TEntity>(param, _properties);

            return(sorter.Sort(_entities));
        }