Exemplo n.º 1
0
        public async Task PerformSearchDatasetVersion_GivenClientReturnsResult_ShouldReturnCorrectlyMappedResult()
        {
            // Arrange
            IDatasetsApiClient mockDatasetsApiClient = Substitute.For <IDatasetsApiClient>();
            ILogger            mockLogger            = Substitute.For <ILogger>();
            IMapper            mockMapper            = MappingHelper.CreateFrontEndMapper();
            IFeatureToggle     featureToggle         = CreateFeatureToggle();

            IDatasetSearchService datasetSearchService = new DatasetSearchService(mockDatasetsApiClient, mockMapper, mockLogger, featureToggle);

            PagedResult <DatasetVersionSearchResultModel> itemResult = GeneratedPagedResultsDatasetVersionSearchResultModel(50);

            itemResult.PageNumber = 2;
            itemResult.PageSize   = 50;
            itemResult.TotalItems = 175;

            mockDatasetsApiClient
            .FindDatasetsVersions(Arg.Any <SearchFilterRequest>())
            .Returns(itemResult);

            // Act
            DatasetVersionSearchResultViewModel datasetVersionSearchResultViewModel = await datasetSearchService.PerformSearchDatasetVersion(new SearchRequestViewModel());

            // Assert
            datasetVersionSearchResultViewModel.Should().NotBeNull();
            datasetVersionSearchResultViewModel.Results.Count().Should().Be(50);
            datasetVersionSearchResultViewModel.TotalResults.Should().Be(175);
            datasetVersionSearchResultViewModel.CurrentPage.Should().Be(2);
            datasetVersionSearchResultViewModel.PageSize.Should().Be(50);
        }
Exemplo n.º 2
0
        public async Task PerformSearchDatasetVersion_GivenClientReturnsEmptyResult_ShouldReturnCorrectlyMappedResult()
        {
            // Arrange
            IDatasetsApiClient mockDatasetsApiClient = Substitute.For <IDatasetsApiClient>();
            ILogger            mockLogger            = Substitute.For <ILogger>();
            IMapper            mockMapper            = MappingHelper.CreateFrontEndMapper();

            IDatasetSearchService datasetSearchService = new DatasetSearchService(mockDatasetsApiClient, mockMapper, mockLogger);

            mockDatasetsApiClient
            .SearchDatasets(Arg.Any <SearchModel>())
            .Returns((ApiResponse <SearchResults <DatasetIndex> >)null);

            // Act
            DatasetVersionSearchResultViewModel datasetVersionSearchResultViewModel = await datasetSearchService.PerformSearchDatasetVersion(new SearchRequestViewModel());

            // Assert
            datasetVersionSearchResultViewModel.Should().BeNull();
        }
Exemplo n.º 3
0
        public async Task PerformSearchDatasetVersion_GivenClientReturnsEmptyResult_ShouldReturnCorrectlyMappedResult()
        {
            // Arrange
            IDatasetsApiClient mockDatasetsApiClient = Substitute.For <IDatasetsApiClient>();
            ILogger            mockLogger            = Substitute.For <ILogger>();
            IMapper            mockMapper            = MappingHelper.CreateFrontEndMapper();
            IFeatureToggle     featureToggle         = CreateFeatureToggle();

            IDatasetSearchService datasetSearchService = new DatasetSearchService(mockDatasetsApiClient, mockMapper, mockLogger, featureToggle);

            mockDatasetsApiClient
            .FindDatasetsVersions(Arg.Any <SearchFilterRequest>())
            .Returns((PagedResult <DatasetVersionSearchResultModel>)null);

            // Act
            DatasetVersionSearchResultViewModel datasetVersionSearchResultViewModel = await datasetSearchService.PerformSearchDatasetVersion(new SearchRequestViewModel());

            // Assert
            datasetVersionSearchResultViewModel.Should().BeNull();
        }