public async Task ProducerAmendmentHasNoRegistrationNumber_ShouldReturnRuleResult() { var scheme = SchemeWithXProducers(1); var schemeId = Guid.NewGuid(); var error = RuleResult.Fail("oops"); A.CallTo(() => amendmentHasNoProducerRegistrationNumber.Evaluate(scheme.producerList.Single())).Returns(error); var result = await XmlBusinessValidator().Validate(scheme, schemeId); Assert.Single(result); Assert.Equal(error, result.Single()); }
public async Task <IEnumerable <RuleResult> > Validate(schemeType scheme, Guid organisationId) { var result = new List <RuleResult>(); // Xml validation only result.AddRange(duplicateProducerRegistrationNumbers.Evaluate(scheme)); result.AddRange(duplicateProducerNames.Evaluate(scheme)); // Now comparing against existing data... result.Add(correctSchemeApprovalNumber.Evaluate(scheme, organisationId)); var producerObligationTypeChange = producerObligationTypeChangeDelegate(organisationId, scheme.complianceYear); // Validate producers foreach (var producer in scheme.producerList) { // Xml validation only result.Add(amendmentHasNoProducerRegistrationNumber.Evaluate(producer)); result.Add(insertHasProducerRegistrationNumber.Evaluate(producer)); result.Add(ukBasedAuthorisedRepresentative.Evaluate(producer)); result.Add(producerNameWarning.Evaluate(scheme, producer, organisationId)); result.Add(annualTurnoverMismatch.Evaluate(producer)); result.Add(ensureAnOverseasProducerIsNotBasedInTheUK.Evaluate(producer)); // Now comparing against existing data... result.Add(producerRegistrationNumberValidity.Evaluate(producer)); result.Add(producerAlreadyRegistered.Evaluate(scheme, producer, organisationId)); result.Add(producerNameAlreadyRegistered.Evaluate()); result.Add(producerChargeBandChangeWarning.Evaluate(scheme, producer, organisationId)); result.Add(companyAlreadyRegistered.Evaluate(producer)); result.Add(companyRegistrationNumberChange.Evaluate(producer)); result.Add(await producerObligationTypeChange.Evaluate(producer)); } return(result.Where(r => r != null && !r.IsValid)); }