protected override async Task <IEnumerable <string> > PerformChecks <T>( T prereqObject, IEnumerable <PublishedProvider> publishedProviders, IEnumerable <Provider> providers) { SpecificationSummary specification = prereqObject as SpecificationSummary; Guard.ArgumentNotNull(specification, nameof(specification)); if (specification.ApprovalStatus != Common.ApiClient.Models.PublishStatus.Approved) { _logger.Error("Specification failed refresh prerequisite check. Reason: must be approved"); return(new string[] { "Specification must be approved." }); } if (providers.IsNullOrEmpty()) { _logger.Error("Specification failed refresh prerequisite check. Reason: no scoped providers"); return(new string[] { "Specification must have providers in scope." }); } SpecificationFundingStatus specificationFundingStatus = await _specificationFundingStatusService.CheckChooseForFundingStatus(specification); if (specificationFundingStatus == SpecificationFundingStatus.SharesAlreadyChosenFundingStream) { string errorMessage = $"Specification with id: '{specification.Id} already shares chosen funding streams"; _logger.Error(errorMessage); return(new string[] { errorMessage }); } if (specificationFundingStatus == SpecificationFundingStatus.CanChoose) { try { await _specificationService.SelectSpecificationForFunding(specification.Id); } catch (Exception ex) { _logger.Error(ex.Message); return(new string[] { ex.Message }); } } List <string> results = new List <string>(); IEnumerable <string> calculationPrereqValidationErrors = await _calculationApprovalCheckerService.VerifyCalculationPrerequisites(specification); if (calculationPrereqValidationErrors.AnyWithNullCheck()) { results.Add("All template calculations for this specification must be approved."); _logger.Error(string.Join(Environment.NewLine, calculationPrereqValidationErrors)); } return(results); }
private void GivenExceptionThrownForSelectSpecificationForFunding(string specificationId, Exception ex) { _specificationService.SelectSpecificationForFunding(specificationId) .Throws(ex); }