Пример #1
0
        public void GetSortExpression_Should_ReturnSortObjectForIdWhenParameterIsInvalid()
        {
            var sort = TodoItem.GetSortExpression("-NoProperty");

            Assert.False(sort.Ascending);
            Assert.Equal(sampleItem.Id, sort.Expression.Compile().Invoke(sampleItem));
        }
Пример #2
0
        public void GetSortExpression_Should_ReturnSortObjectForIdWhenParameterIsEmpty()
        {
            var sort = TodoItem.GetSortExpression(string.Empty);

            Assert.True(sort.Ascending);
            Assert.Equal(sampleItem.Id, sort.Expression.Compile().Invoke(sampleItem));
        }
Пример #3
0
        public void GetSortExpression_Should_ReturnSortObjectForIdWhenParameterContainsOnlyTheOrder()
        {
            var sort = TodoItem.GetSortExpression("-");

            Assert.False(sort.Ascending);
            Assert.Equal(sampleItem.Id, sort.Expression.Compile().Invoke(sampleItem));
        }
Пример #4
0
        public void GetSortExpression_Should_ReturnAscendingWhenThereIsPlusSign()
        {
            var sort = TodoItem.GetSortExpression("+title");

            Assert.True(sort.Ascending);
            Assert.Equal(sampleItem.Title, sort.Expression.Compile().Invoke(sampleItem));
        }
Пример #5
0
        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));
        }
Пример #6
0
        public void GetSortExpression_Should_ReturnSortObjectForIsCompleted()
        {
            var sort = TodoItem.GetSortExpression("isCompleted");

            Assert.Equal(sampleItem.IsCompleted, sort.Expression.Compile().Invoke(sampleItem));
        }
Пример #7
0
        public void GetSortExpression_Should_ReturnSortObjectForDescription()
        {
            var sort = TodoItem.GetSortExpression("description");

            Assert.Equal(sampleItem.Description, sort.Expression.Compile().Invoke(sampleItem));
        }
Пример #8
0
        public void GetSortExpression_Should_ReturnSortObjectForTitle()
        {
            var sort = TodoItem.GetSortExpression("title");

            Assert.Equal(sampleItem.Title, sort.Expression.Compile().Invoke(sampleItem));
        }
Пример #9
0
        public void GetSortExpression_Should_ReturnDescendingWhenThereIsMinusSign()
        {
            var sort = TodoItem.GetSortExpression("-title");

            Assert.False(sort.Ascending);
        }