public async Task GetDatasetAggregations_GivenSpecificationIdButNullAggregationsFound_ReturnsOKObjectWithEmptyList()
        {
            //Arrange
            IDatasetsAggregationsRepository datasetsAggregationsRepository = CreateDatasetsAggregationsRepository();

            datasetsAggregationsRepository
            .GetDatasetAggregationsForSpecificationId(Arg.Is(SpecificationId))
            .Returns((IEnumerable <DatasetAggregations>)null);

            ProcessDatasetService processDatasetService = CreateProcessDatasetService(datasetsAggregationsRepository: datasetsAggregationsRepository);

            //Act
            IActionResult result = await processDatasetService.GetDatasetAggregationsBySpecificationId(SpecificationId);

            //Assert
            result
            .Should()
            .BeOfType <OkObjectResult>()
            .Which
            .Value
            .Should()
            .BeOfType <DatasetAggregations[]>()
            .Which
            .Length
            .Should()
            .Be(0);
        }
        public async Task GetDatasetAggregations_GivenSpecificationIdAndTwoAggregationsFound_ReturnsOKObjectWithTwoItems()
        {
            //Arrange
            IEnumerable <DatasetAggregations> datasetAggregations = new[]
            {
                new DatasetAggregations(),
                new DatasetAggregations()
            };

            IDatasetsAggregationsRepository datasetsAggregationsRepository = CreateDatasetsAggregationsRepository();

            datasetsAggregationsRepository
            .GetDatasetAggregationsForSpecificationId(Arg.Is(SpecificationId))
            .Returns(datasetAggregations);

            ProcessDatasetService processDatasetService = CreateProcessDatasetService(datasetsAggregationsRepository: datasetsAggregationsRepository);

            //Act
            IActionResult result = await processDatasetService.GetDatasetAggregationsBySpecificationId(SpecificationId);

            //Assert
            result
            .Should()
            .BeOfType <OkObjectResult>()
            .Which
            .Value
            .Should()
            .BeOfType <DatasetAggregations[]>()
            .Which
            .Length
            .Should()
            .Be(2);
        }
Example #3
0
        public ProcessDatasetService(
            IDatasetRepository datasetRepository,
            IExcelDatasetReader excelDatasetReader,
            ICacheProvider cacheProvider,
            ICalcsRepository calcsRepository,
            IBlobClient blobClient,
            IMessengerService messengerService,
            IProvidersResultsRepository providersResultsRepository,
            IResultsRepository resultsRepository,
            IProviderService providerService,
            IVersionRepository <ProviderSourceDatasetVersion> sourceDatasetsVersionRepository,
            ILogger logger,
            ITelemetry telemetry,
            IDatasetsResiliencePolicies datasetsResiliencePolicies,
            IDatasetsAggregationsRepository datasetsAggregationsRepository,
            IFeatureToggle featureToggle,
            IJobsApiClient jobsApiClient)
        {
            Guard.ArgumentNotNull(datasetRepository, nameof(datasetRepository));
            Guard.ArgumentNotNull(excelDatasetReader, nameof(excelDatasetReader));
            Guard.ArgumentNotNull(cacheProvider, nameof(cacheProvider));
            Guard.ArgumentNotNull(messengerService, nameof(messengerService));
            Guard.ArgumentNotNull(calcsRepository, nameof(calcsRepository));
            Guard.ArgumentNotNull(providersResultsRepository, nameof(providersResultsRepository));
            Guard.ArgumentNotNull(resultsRepository, nameof(resultsRepository));
            Guard.ArgumentNotNull(providerService, nameof(providerService));
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(telemetry, nameof(telemetry));
            Guard.ArgumentNotNull(datasetsAggregationsRepository, nameof(datasetsAggregationsRepository));
            Guard.ArgumentNotNull(featureToggle, nameof(featureToggle));
            Guard.ArgumentNotNull(jobsApiClient, nameof(jobsApiClient));

            _datasetRepository               = datasetRepository;
            _excelDatasetReader              = excelDatasetReader;
            _cacheProvider                   = cacheProvider;
            _calcsRepository                 = calcsRepository;
            _blobClient                      = blobClient;
            _providersResultsRepository      = providersResultsRepository;
            _resultsRepository               = resultsRepository;
            _providerService                 = providerService;
            _sourceDatasetsVersionRepository = sourceDatasetsVersionRepository;
            _logger    = logger;
            _telemetry = telemetry;
            _providerResultsRepositoryPolicy = datasetsResiliencePolicies.ProviderResultsRepository;
            _datasetsAggregationsRepository  = datasetsAggregationsRepository;
            _featureToggle       = featureToggle;
            _jobsApiClient       = jobsApiClient;
            _jobsApiClientPolicy = datasetsResiliencePolicies.JobsApiClient;
            _messengerService    = messengerService;
        }
 protected static ProcessDatasetService CreateProcessDatasetService(
     IBlobClient blobClient             = null,
     IMessengerService messengerService = null,
     ILogger logger = null,
     IDatasetRepository datasetRepository                        = null,
     IExcelDatasetReader excelDatasetReader                      = null,
     ICacheProvider cacheProvider                                = null,
     ICalcsRepository calcsRepository                            = null,
     IProvidersApiClient providersApiClient                      = null,
     ISpecificationsApiClient specificationsApiClient            = null,
     IProviderSourceDatasetsRepository providerResultsRepository = null,
     ITelemetry telemetry = null,
     IDatasetsResiliencePolicies datasetsResiliencePolicies         = null,
     IDatasetsAggregationsRepository datasetsAggregationsRepository = null,
     IFeatureToggle featureToggle = null,
     IMapper mapper = null,
     IJobManagement jobManagement = null,
     IProviderSourceDatasetVersionKeyProvider versionKeyProvider = null,
     IJobsApiClient jobsApiClient = null,
     IVersionBulkRepository <ProviderSourceDatasetVersion> versionBulkRepository = null,
     IProviderSourceDatasetBulkRepository providerSourceDatasetBulkRepository    = null)
 {
     return(new ProcessDatasetService(
                datasetRepository ?? CreateDatasetsRepository(),
                excelDatasetReader ?? CreateExcelDatasetReader(),
                cacheProvider ?? CreateCacheProvider(),
                calcsRepository ?? CreateCalcsRepository(),
                blobClient ?? CreateBlobClient(),
                messengerService ?? CreateMessengerService(),
                providerResultsRepository ?? CreateProviderResultsRepository(),
                providersApiClient ?? CreateProvidersApiClient(),
                specificationsApiClient ?? CreateSpecificationsApiClient(),
                logger ?? CreateLogger(),
                datasetsResiliencePolicies ?? DatasetsResilienceTestHelper.GenerateTestPolicies(),
                datasetsAggregationsRepository ?? CreateDatasetsAggregationsRepository(),
                featureToggle ?? CreateFeatureToggle(),
                mapper ?? CreateMapper(),
                jobManagement ?? CreateJobManagement(),
                versionKeyProvider ?? CreateDatasetVersionKeyProvider(),
                versionBulkRepository ?? new Mock <IVersionBulkRepository <ProviderSourceDatasetVersion> >().Object,
                providerSourceDatasetBulkRepository ?? new Mock <IProviderSourceDatasetBulkRepository>().Object));
 }
 protected static ProcessDatasetService CreateProcessDatasetService(
     IBlobClient blobClient             = null,
     IMessengerService messengerService = null,
     ILogger logger = null,
     IDatasetRepository datasetRepository   = null,
     IExcelDatasetReader excelDatasetReader = null,
     ICacheProvider cacheProvider           = null,
     ICalcsRepository calcsRepository       = null,
     IProviderService providerService       = null,
     IResultsRepository resultsRepository   = null,
     IProvidersResultsRepository providerResultsRepository = null,
     ITelemetry telemetry = null,
     IDatasetsResiliencePolicies datasetsResiliencePolicies = null,
     IVersionRepository <ProviderSourceDatasetVersion> versionRepository = null,
     IDatasetsAggregationsRepository datasetsAggregationsRepository      = null,
     IFeatureToggle featureToggle = null,
     IJobsApiClient jobsApiClient = null)
 {
     return(new ProcessDatasetService(
                datasetRepository ?? CreateDatasetsRepository(),
                excelDatasetReader ?? CreateExcelDatasetReader(),
                cacheProvider ?? CreateCacheProvider(),
                calcsRepository ?? CreateCalcsRepository(),
                blobClient ?? CreateBlobClient(),
                messengerService ?? CreateMessengerService(),
                providerResultsRepository ?? CreateProviderResultsRepository(),
                resultsRepository ?? CreateResultsRepository(),
                providerService ?? CreateProviderService(),
                versionRepository ?? CreateVersionRepository(),
                logger ?? CreateLogger(),
                telemetry ?? CreateTelemetry(),
                datasetsResiliencePolicies ?? DatasetsResilienceTestHelper.GenerateTestPolicies(),
                datasetsAggregationsRepository ?? CreateDatasetsAggregationsRepository(),
                featureToggle ?? CreateFeatureToggle(),
                jobsApiClient ?? CreateJobsApiClient()));
 }