Beispiel #1
0
        public async Task GetPagedList_Success()
        {
            List <VehicleModel> vehicleModelList = new List <VehicleModel>
            {
                new VehicleModel {
                    Id = 2, MakeId = 1, Name = "X2", Abrv = "x2"
                },
                new VehicleModel {
                    Id = 3, MakeId = 2, Name = "X1", Abrv = "x1"
                }
            };
            var filter = new Filter
            {
                Search      = null,
                IsAscending = false,
                PageNumber  = 1,
                TotalCount  = 2
            };

            modelRepository.Setup(x => x.GetPagedModel(filter))
            .ReturnsAsync(new StaticPagedList <VehicleModel>(vehicleModelList,
                                                             filter.PageNumber, filter.PageSize, filter.TotalCount));
            var vehicleModelService = new VehicleModelService(modelRepository.Object);
            var result = await vehicleModelService.PagedList(filter);

            result.Should().NotBeNull();
            result.PageNumber.ShouldBeEquivalentTo(1);
            result.TotalItemCount.ShouldBeEquivalentTo(2);
            result.ToList().Count().ShouldBeEquivalentTo(2);
        }