Пример #1
0
        public void SortModifier_MultipleSortsOneByOne_ReturnsCorrectQueryParam()
        {
            // Arrange
            var modifier = new SortModifier <TestSort>();
            Func <TestSort, SortExpression> sortExpression1 = (f) => f.Id.Asc();
            Func <TestSort, SortExpression> sortExpression2 = (f) => f.Name.Desc();

            modifier.Sort(sortExpression1);
            modifier.Sort(sortExpression2);

            // Act
            var queryParams = modifier.GetQueryParameters();

            // Assert
            Assert.AreEqual(1, queryParams.Count);
            Assert.IsTrue(queryParams.TryGetValue("sort", out var sort));
            var sort1 = GetSortExpression(sortExpression1);
            var sort2 = GetSortExpression(sortExpression2);

            Assert.AreEqual($"{sort1}|{sort2}", sort);
        }
Пример #2
0
        public void SortModifier_SingleSort_ReturnsCorrectQueryParam()
        {
            // Arrange
            var modifier = new SortModifier <TestSort>();
            Func <TestSort, SortExpression> sortExpression = (f) => f.Id.Asc();

            modifier.Sort(sortExpression);

            // Act
            var queryParams = modifier.GetQueryParameters();

            // Assert
            Assert.AreEqual(1, queryParams.Count);
            Assert.IsTrue(queryParams.TryGetValue("sort", out var sort));
            var sortString = GetSortExpression(sortExpression);

            Assert.AreEqual(sortString, sort);
        }
Пример #3
0
 /// <summary>
 /// Sorting of a list.
 /// </summary>
 /// <param name="sort">Sort expressions.</param>
 /// <returns>List of models.</returns>
 public TList Sort(params Func <TSort, SortExpression>[] sort)
 {
     _sort.Sort(sort);
     return(This);
 }