Esempio n. 1
0
        public void SetUp()
        {
            _calculationResultsRepository = Substitute.For <ICalculationResultsRepository>();
            _blobClient              = Substitute.For <IBlobClient>();
            _csvUtils                = Substitute.For <ICsvUtils>();
            _transformation          = Substitute.For <IProviderResultsToCsvRowsTransformation>();
            _cloudBlob               = Substitute.For <ICloudBlob>();
            _fileSystemAccess        = Substitute.For <IFileSystemAccess>();
            _fileSystemCacheSettings = Substitute.For <IFileSystemCacheSettings>();
            _jobManagement           = Substitute.For <IJobManagement>();
            _calcsApiClient          = Substitute.For <ICalculationsApiClient>();
            _specsApiClient          = Substitute.For <ISpecificationsApiClient>();

            _service = new ProviderResultsCsvGeneratorService(Substitute.For <ILogger>(),
                                                              _blobClient,
                                                              _calcsApiClient,
                                                              _specsApiClient,
                                                              _calculationResultsRepository,
                                                              new ResiliencePolicies
            {
                BlobClient              = Policy.NoOpAsync(),
                CalculationsApiClient   = Policy.NoOpAsync(),
                SpecificationsApiClient = Policy.NoOpAsync(),
                ResultsRepository       = Policy.NoOpAsync()
            },
                                                              _csvUtils,
                                                              _transformation,
                                                              _fileSystemAccess,
                                                              _fileSystemCacheSettings,
                                                              _jobManagement);

            _message  = new Message();
            _rootPath = NewRandomString();

            _fileSystemCacheSettings.Path
            .Returns(_rootPath);

            _fileSystemAccess
            .Append(Arg.Any <string>(), Arg.Any <Stream>())
            .Returns(Task.CompletedTask);

            _blobProperties = new BlobProperties();

            _cloudBlob
            .Properties
            .Returns(_blobProperties);
        }
        public ProviderResultsCsvGeneratorService(ILogger logger,
                                                  IBlobClient blobClient,
                                                  ICalculationsApiClient calculationsApiClient,
                                                  ISpecificationsApiClient specificationsApiClient,
                                                  ICalculationResultsRepository resultsRepository,
                                                  IResultsResiliencePolicies policies,
                                                  ICsvUtils csvUtils,
                                                  IProviderResultsToCsvRowsTransformation resultsToCsvRowsTransformation,
                                                  IFileSystemAccess fileSystemAccess,
                                                  IFileSystemCacheSettings fileSystemCacheSettings,
                                                  IJobManagement jobManagement) : base(jobManagement, logger)
        {
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(blobClient, nameof(blobClient));
            Guard.ArgumentNotNull(specificationsApiClient, nameof(specificationsApiClient));
            Guard.ArgumentNotNull(calculationsApiClient, nameof(calculationsApiClient));
            Guard.ArgumentNotNull(resultsRepository, nameof(resultsRepository));
            Guard.ArgumentNotNull(resultsToCsvRowsTransformation, nameof(resultsToCsvRowsTransformation));
            Guard.ArgumentNotNull(fileSystemAccess, nameof(fileSystemAccess));
            Guard.ArgumentNotNull(policies?.BlobClient, nameof(policies.BlobClient));
            Guard.ArgumentNotNull(policies?.CalculationsApiClient, nameof(policies.CalculationsApiClient));
            Guard.ArgumentNotNull(policies?.SpecificationsApiClient, nameof(policies.SpecificationsApiClient));
            Guard.ArgumentNotNull(policies?.ResultsRepository, nameof(policies.ResultsRepository));
            Guard.ArgumentNotNull(fileSystemCacheSettings, nameof(fileSystemCacheSettings));
            Guard.ArgumentNotNull(jobManagement, nameof(jobManagement));

            _logger                         = logger;
            _blobClient                     = blobClient;
            _calculationsApiClient          = calculationsApiClient;
            _specificationsApiClient        = specificationsApiClient;
            _resultsRepository              = resultsRepository;
            _blobClientPolicy               = policies.BlobClient;
            _calculationsApiClientPolicy    = policies.CalculationsApiClient;
            _specificationsApiClientPolicy  = policies.SpecificationsApiClient;
            _resultsRepositoryPolicy        = policies.ResultsRepository;
            _csvUtils                       = csvUtils;
            _resultsToCsvRowsTransformation = resultsToCsvRowsTransformation;
            _fileSystemAccess               = fileSystemAccess;
            _fileSystemCacheSettings        = fileSystemCacheSettings;
            _jobManagement                  = jobManagement;
        }