public void GetPaged_PagedParamBase_Page_1_PageSize_10_OrderByAsc_Empty()
        {
            var param = new PagedParamBase
            {
                Page     = 1,
                PageSize = 10,
                Ordering = new KeyValuePair <string, Ordering>(string.Empty, Ordering.Ascending)
            };
            var first  = Context.People.FirstOrDefault();
            var result = Context.People.GetPaged(param);

            Assert.Equal(param.PageSize, result.PageSize);
            Assert.Equal(TotalElements, result.RowCount);
            Assert.Equal(param.Page, result.CurrentPage);
            Assert.True(first.Equal(result.Results.FirstOrDefault()));
        }
        public void GetPaged_PagedParamBase_Page_1_PageSize_10_OrderByDesc_FirstName()
        {
            var param = new PagedParamBase
            {
                Page     = 1,
                PageSize = 10,
                Ordering = new KeyValuePair <string, Ordering>(nameof(PersonEntity.FirstName), Ordering.Descending)
            };
            var data   = Context.People.OrderByDescending(x => x.FirstName);
            var first  = data.FirstOrDefault();
            var result = Context.People.GetPaged(param);

            Assert.Equal(param.PageSize, result.PageSize);
            Assert.Equal(TotalElements, result.RowCount);
            Assert.Equal(param.Page, result.CurrentPage);
            Assert.True(first.Equal(result.Results.FirstOrDefault()));
        }
        public void GetPaged_PagedParamBase_Page_1_PageSize_10_Filter_Value_Throw_FilterNullException()
        {
            var param = new PagedParamBase
            {
                Page     = 1,
                PageSize = 10,
                Filters  = new List <Filter>
                {
                    new Filter
                    {
                        Key        = "SomeThing",
                        Value      = null,
                        Comparison = ComparisonOperators.StartWith,
                    }
                }
            };

            Assert.Throws <FilterNullException>(() => Context.People.GetPaged(param));
        }
        public void GetPaged_PagedParamBase_Page_1_PageSize_10_Filter_Value_Not_Same_Type()
        {
            var param = new PagedParamBase
            {
                Page     = 1,
                PageSize = 10,
                Filters  = new List <Filter>
                {
                    new Filter
                    {
                        Key        = nameof(PersonEntity.IdPerson),
                        Value      = "Value",
                        Comparison = ComparisonOperators.None,
                    }
                }
            };
            var first  = Context.People.FirstOrDefault();
            var result = Context.People.GetPaged(param);

            Assert.Equal(param.PageSize, result.PageSize);
            Assert.Equal(TotalElements, result.RowCount);
            Assert.Equal(param.Page, result.CurrentPage);
            Assert.True(first.Equal(result.Results.FirstOrDefault()));
        }
        public void GetPaged_PagedParamBase_Page_1_PageSize_10_Filter_KeyProperty_Not_Exist()
        {
            var param = new PagedParamBase
            {
                Page     = 1,
                PageSize = 10,
                Filters  = new List <Filter>
                {
                    new Filter
                    {
                        Key        = "SomeThing",
                        Value      = "Value",
                        Comparison = ComparisonOperators.None,
                    }
                }
            };
            var first  = Context.People.FirstOrDefault();
            var result = Context.People.GetPaged(param);

            Assert.Equal(param.PageSize, result.PageSize);
            Assert.Equal(TotalElements, result.RowCount);
            Assert.Equal(param.Page, result.CurrentPage);
            Assert.True(first.Equal(result.Results.FirstOrDefault()));
        }