public void SetUp()
        {
            _policies = Substitute.For <IPoliciesApiClient>();
            _specificationApiClient           = Substitute.For <ISpecificationsApiClient>();
            _graphRepository                  = Substitute.For <IGraphRepository>();
            _createCalculationService         = Substitute.For <ICreateCalculationService>();
            _calculationsRepository           = Substitute.For <ICalculationsRepository>();
            _instructionAllocationJobCreation = Substitute.For <IInstructionAllocationJobCreation>();
            _calculationService               = Substitute.For <ICalculationService>();
            _cacheProvider    = Substitute.For <ICacheProvider>();
            _codeContextCache = Substitute.For <ICodeContextCache>();
            _jobManagement    = Substitute.For <IJobManagement>();

            _userId          = $"{NewRandomString()}_userId";
            _userName        = $"{NewRandomString()}_userName";
            _correlationId   = $"{NewRandomString()}_correlationId";
            _specificationId = $"{NewRandomString()}_specificationId";
            _fundingStreamId = $"{NewRandomString()}_fundingStreamId";
            _fundingPeriodId = $"{NewRandomString()}_fundingPeriodId";
            _templateVersion = $"{NewRandomString()}_templateVersion";
            _jobId           = $"{NewRandomString()}_jobId";

            _calculationsRepository.UpdateTemplateMapping(Arg.Any <string>(),
                                                          Arg.Any <string>(),
                                                          Arg.Any <TemplateMapping>())
            .Returns(Task.CompletedTask);

            _service = new ApplyTemplateCalculationsService(_createCalculationService,
                                                            _policies,
                                                            new ResiliencePolicies
            {
                PoliciesApiClient       = Policy.NoOpAsync(),
                CalculationsRepository  = Policy.NoOpAsync(),
                CacheProviderPolicy     = Policy.NoOpAsync(),
                SpecificationsApiClient = Policy.NoOpAsync()
            },
                                                            _calculationsRepository,
                                                            _jobManagement,
                                                            _instructionAllocationJobCreation,
                                                            Substitute.For <ILogger>(),
                                                            _calculationService,
                                                            _cacheProvider,
                                                            _specificationApiClient,
                                                            _graphRepository,
                                                            _codeContextCache);
        }
Beispiel #2
0
        public ApplyTemplateCalculationsService(
            ICreateCalculationService createCalculationService,
            IPoliciesApiClient policiesApiClient,
            ICalcsResiliencePolicies calculationsResiliencePolicies,
            ICalculationsRepository calculationsRepository,
            IJobManagement jobManagement,
            IInstructionAllocationJobCreation instructionAllocationJobCreation,
            ILogger logger,
            ICalculationService calculationService,
            ICacheProvider cacheProvider,
            ISpecificationsApiClient specificationsApiClient,
            IGraphRepository graphRepository,
            ICodeContextCache codeContextCache) : base(jobManagement, logger)
        {
            Guard.ArgumentNotNull(instructionAllocationJobCreation, nameof(instructionAllocationJobCreation));
            Guard.ArgumentNotNull(createCalculationService, nameof(createCalculationService));
            Guard.ArgumentNotNull(policiesApiClient, nameof(policiesApiClient));
            Guard.ArgumentNotNull(calculationsRepository, nameof(calculationsRepository));
            Guard.ArgumentNotNull(calculationsResiliencePolicies?.PoliciesApiClient, nameof(calculationsResiliencePolicies.PoliciesApiClient));
            Guard.ArgumentNotNull(calculationsResiliencePolicies?.CalculationsRepository, nameof(calculationsResiliencePolicies.CalculationsRepository));
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(calculationService, nameof(calculationService));
            Guard.ArgumentNotNull(calculationsResiliencePolicies?.CacheProviderPolicy, nameof(calculationsResiliencePolicies.CacheProviderPolicy));
            Guard.ArgumentNotNull(cacheProvider, nameof(cacheProvider));
            Guard.ArgumentNotNull(graphRepository, nameof(graphRepository));
            Guard.ArgumentNotNull(specificationsApiClient, nameof(specificationsApiClient));

            _createCalculationService     = createCalculationService;
            _calculationsRepository       = calculationsRepository;
            _policiesApiClient            = policiesApiClient;
            _policiesResiliencePolicy     = calculationsResiliencePolicies.PoliciesApiClient;
            _calculationsRepositoryPolicy = calculationsResiliencePolicies.CalculationsRepository;
            _logger = logger;
            _instructionAllocationJobCreation = instructionAllocationJobCreation;
            _calculationService            = calculationService;
            _cachePolicy                   = calculationsResiliencePolicies.CacheProviderPolicy;
            _cacheProvider                 = cacheProvider;
            _specificationsApiClient       = specificationsApiClient;
            _codeContextCache              = codeContextCache;
            _specificationsApiClientPolicy = calculationsResiliencePolicies.SpecificationsApiClient;
        }