/// <summary> /// Get query parameters. /// </summary> /// <returns>Dictionary of query parameters.</returns> protected Dictionary <string, string> GetQueryParameters() { var queryParams = new Dictionary <string, string>(); queryParams.AddRange(_filter.GetQueryParameters()); queryParams.AddRange(_sort.GetQueryParameters()); return(queryParams); }
public void SortModifier_WithoutSort_ReturnsNull() { // Arrange var modifier = new SortModifier <TestSort>(); // Act var queryParams = modifier.GetQueryParameters(); // Assert Assert.IsNull(queryParams); }
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); }
public void SortModifier_MultipleSortsAtOnce_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, 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); }