public void GetSortExpression_Should_ReturnSortObjectForIdWhenParameterIsInvalid() { var sort = TodoItem.GetSortExpression("-NoProperty"); Assert.False(sort.Ascending); Assert.Equal(sampleItem.Id, sort.Expression.Compile().Invoke(sampleItem)); }
public void GetSortExpression_Should_ReturnSortObjectForIdWhenParameterIsEmpty() { var sort = TodoItem.GetSortExpression(string.Empty); Assert.True(sort.Ascending); Assert.Equal(sampleItem.Id, sort.Expression.Compile().Invoke(sampleItem)); }
public void GetSortExpression_Should_ReturnSortObjectForIdWhenParameterContainsOnlyTheOrder() { var sort = TodoItem.GetSortExpression("-"); Assert.False(sort.Ascending); Assert.Equal(sampleItem.Id, sort.Expression.Compile().Invoke(sampleItem)); }
public void GetSortExpression_Should_ReturnAscendingWhenThereIsPlusSign() { var sort = TodoItem.GetSortExpression("+title"); Assert.True(sort.Ascending); Assert.Equal(sampleItem.Title, sort.Expression.Compile().Invoke(sampleItem)); }
public async Task <ActionResult <Page <TodoItem> > > GetTodoItems(Filter filter, string sort, PageData pageData) { var entityFilter = _mapper.Map <TodoItemFilter>(filter); var sortOrder = TodoItem.GetSortExpression(sort); var itemEntities = await _service.Find(entityFilter, sortOrder, pageData.Page, pageData.PageSize); var items = _mapper.Map <Page <TodoItem> >(itemEntities); return(Ok(items)); }
public void GetSortExpression_Should_ReturnSortObjectForIsCompleted() { var sort = TodoItem.GetSortExpression("isCompleted"); Assert.Equal(sampleItem.IsCompleted, sort.Expression.Compile().Invoke(sampleItem)); }
public void GetSortExpression_Should_ReturnSortObjectForDescription() { var sort = TodoItem.GetSortExpression("description"); Assert.Equal(sampleItem.Description, sort.Expression.Compile().Invoke(sampleItem)); }
public void GetSortExpression_Should_ReturnSortObjectForTitle() { var sort = TodoItem.GetSortExpression("title"); Assert.Equal(sampleItem.Title, sort.Expression.Compile().Invoke(sampleItem)); }
public void GetSortExpression_Should_ReturnDescendingWhenThereIsMinusSign() { var sort = TodoItem.GetSortExpression("-title"); Assert.False(sort.Ascending); }