public async Task GetUsersPaging_HasFilter_ReturnSuccess()
        {
            _localizer = MockLocalizer();
            _context.Functions.AddRange(new List <Function>()
            {
                new Function()
                {
                    Id        = "GetUsersPaging_HasFilter_ReturnSuccess",
                    ParentId  = null,
                    NameTemp  = "GetUsersPaging_HasFilter_ReturnSuccess",
                    SortOrder = 3,
                    Url       = "/GetUsersPaging_HasFilter_ReturnSuccess"
                }
            });
            await _context.SaveChangesAsync();

            var controller = new FunctionsController(_context, _mockLogger.Object, _mapper, _localizer, _returnString);
            var result     = await controller.GetFunctionsPaging("GetUsersPaging_HasFilter_ReturnSuccess", 1, 2);

            var okResult = result as OkObjectResult;
            var UserVms  = okResult.Value as Pagination <FunctionVm>;

            Assert.Equal(1, UserVms.TotalRecords);
            Assert.Single(UserVms.Items);
        }
        public async Task GetFunctionsPaging_NoFilter_ReturnSuccess()
        {
            _localizer = MockLocalizer();
            _context.Functions.AddRange(new List <Function>()
            {
                new Function()
                {
                    Id        = "GetFunctionsPaging_NoFilter_ReturnSuccess1",
                    ParentId  = null,
                    NameTemp  = "GetFunctionsPaging_NoFilter_ReturnSuccess1",
                    SortOrder = 1,
                    Url       = "/test1"
                },
                new Function()
                {
                    Id        = "GetFunctionsPaging_NoFilter_ReturnSuccess2",
                    ParentId  = null,
                    NameTemp  = "GetFunctionsPaging_NoFilter_ReturnSuccess2",
                    SortOrder = 2,
                    Url       = "/test2"
                },
                new Function()
                {
                    Id        = "GetFunctionsPaging_NoFilter_ReturnSuccess3",
                    ParentId  = null,
                    NameTemp  = "GetFunctionsPaging_NoFilter_ReturnSuccess3",
                    SortOrder = 3,
                    Url       = "/test3"
                },
                new Function()
                {
                    Id        = "GetFunctionsPaging_NoFilter_ReturnSuccess4",
                    ParentId  = null,
                    NameTemp  = "GetFunctionsPaging_NoFilter_ReturnSuccess4",
                    SortOrder = 4,
                    Url       = "/test4"
                }
            });
            await _context.SaveChangesAsync();

            var controller = new FunctionsController(_context, _mockLogger.Object, _mapper, _localizer, _returnString);
            var result     = await controller.GetFunctionsPaging(null, 1, 2);

            var okResult = result as OkObjectResult;
            var UserVms  = okResult.Value as Pagination <FunctionVm>;

            Assert.Equal(4, UserVms.TotalRecords);
            Assert.Equal(2, UserVms.Items.Count);
        }
示例#3
0
        public async Task GetFunctionsPaging_NoFilter_ReturnSuccess()
        {
            _context.Functions.AddRange(new List <Function>()
            {
                new Function()
                {
                    Id        = "GetFunctionsPaging_NoFilter_ReturnSuccess1",
                    ParentId  = null,
                    Name      = "GetFunctionsPaging_NoFilter_ReturnSuccess1",
                    SortOrder = 1,
                    Url       = "/test1"
                },
                new Function()
                {
                    Id        = "GetFunctionsPaging_NoFilter_ReturnSuccess2",
                    ParentId  = null,
                    Name      = "GetFunctionsPaging_NoFilter_ReturnSuccess2",
                    SortOrder = 2,
                    Url       = "/test2"
                },
                new Function()
                {
                    Id        = "GetFunctionsPaging_NoFilter_ReturnSuccess3",
                    ParentId  = null,
                    Name      = "GetFunctionsPaging_NoFilter_ReturnSuccess3",
                    SortOrder = 3,
                    Url       = "/test3"
                },
                new Function()
                {
                    Id        = "GetFunctionsPaging_NoFilter_ReturnSuccess4",
                    ParentId  = null,
                    Name      = "GetFunctionsPaging_NoFilter_ReturnSuccess4",
                    SortOrder = 4,
                    Url       = "/test4"
                }
            });
            await _context.SaveChangesAsync();

            var functionsController = new FunctionsController(_context);
            var result = await functionsController.GetFunctionsPaging(null, 1, 2);

            var okResult   = result as OkObjectResult;
            var functionVm = okResult.Value as Pagination <FunctionVm>;

            Assert.Equal(4, functionVm.TotalRecords);
            Assert.Equal(2, functionVm.Items.Count);
        }
示例#4
0
        public async Task GetFunctionsPaging_HasFilter_ReturnSuccess()
        {
            _context.Functions.AddRange(new List <Function>()
            {
                new Function()
                {
                    Id        = "GetFunctionsPaging_HasFilter_ReturnSuccess",
                    ParentId  = null,
                    Name      = "GetFunctionsPaging_HasFilter_ReturnSuccess",
                    SortOrder = 3,
                    Url       = "/GetFunctionsPaging_HasFilter_ReturnSuccess"
                }
            });
            await _context.SaveChangesAsync();

            var functionsController = new FunctionsController(_context);
            var result = await functionsController.GetFunctionsPaging("GetFunctionsPaging_HasFilter_ReturnSuccess", 1, 2);

            var okResult   = result as OkObjectResult;
            var functionVm = okResult.Value as Pagination <FunctionVm>;

            Assert.Equal(1, functionVm.TotalRecords);
            Assert.Single(functionVm.Items);
        }