Beispiel #1
0
        public object GetExamples()
        {
            var services          = InitDefaults.GetInitialServices();
            var servicePagingList = new PaginatedList <Service>(services, 1, 5);
            var serviceListDto    = new ServiceListDto(servicePagingList, _mapper);

            return(serviceListDto);
        }
        public async void AllServicesAllDefaultsShouldBeGotSuccess()
        {
            //Arrange
            var getServicesListDto = new GetServicesListDto {
            };
            var initServices       = InitDefaults.GetInitialServices();

            //Act
            var services = await _servicesService.GetAllServicesAsync(Guid.NewGuid(), getServicesListDto);

            //Assert
            Assert.Equal(services.TotalItems, initServices.Count);
            Assert.Equal(services.Items.Count, _settings.PageSize);
            Assert.Equal(services.PageSize, _settings.PageSize);
            Assert.Equal(1, services.CurrentPage);
            Assert.Equal((int)Math.Ceiling(services.TotalItems / (double)services.PageSize), services.TotalPages);
        }
        public async void ApplyFilterServicesShouldBeGotSuccess()
        {
            //Arrange
            var getServicesListDto = new GetServicesListDto
            {
                Filter = "ic"
            };

            var initServicesFiltered = InitDefaults.GetInitialServices()
                                       .Where(s => s.Name.Contains(getServicesListDto.Filter))
                                       .ToList();

            //Act
            var services = await _servicesService.GetAllServicesAsync(Guid.NewGuid(), getServicesListDto);

            //Assert
            Assert.Equal(initServicesFiltered.Count(), services.TotalItems);
            AssertServices(initServicesFiltered, services.Items);
        }