public void Evaluate_ProducerHasOverseasContactInFrance_Passes() { // Arrange EnsureAnOverseasProducerIsNotBasedInTheUK rule = new EnsureAnOverseasProducerIsNotBasedInTheUK(); addressType address = new addressType(); address.country = countryType.FRANCE; contactDetailsType overseasContact = new contactDetailsType(); overseasContact.address = address; overseasProducerType overseasProducer = new overseasProducerType(); overseasProducer.overseasContact = overseasContact; authorisedRepresentativeType authorisedRepresentative = new authorisedRepresentativeType(); authorisedRepresentative.overseasProducer = overseasProducer; producerType producer = new producerType(); producer.authorisedRepresentative = authorisedRepresentative; // Act RuleResult result = rule.Evaluate(producer); // Assert Assert.Equal(true, result.IsValid); }
public async void SetAuthorisedRepresentative_WithRepresentativeOverseasProducer_WithContact_ReturnsOverseasProducerWithContact() { string forename = "forename"; string surname = "surname"; var authorisedRepresentative = new authorisedRepresentativeType() { overseasProducer = new overseasProducerType() { overseasContact = new contactDetailsType() { address = new addressType() { country = countryType.UKENGLAND }, forename = forename, surname = surname } } }; var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.DataAccess.GetCountry(A <string> ._)).Returns(new Country(Guid.NewGuid(), "BELARUS")); var result = await builder.Build().SetAuthorisedRepresentative(authorisedRepresentative); Assert.Equal(forename, authorisedRepresentative.overseasProducer.overseasContact.forename); Assert.Equal(surname, authorisedRepresentative.overseasProducer.overseasContact.surname); }
public void Evaluate_ProducerHasOverseaseContactInEngland_FailsWithError() { // Arrange EnsureAnOverseasProducerIsNotBasedInTheUK rule = new EnsureAnOverseasProducerIsNotBasedInTheUK(); addressType address = new addressType(); address.country = countryType.UKENGLAND; contactDetailsType overseasContact = new contactDetailsType(); overseasContact.address = address; overseasProducerType overseasProducer = new overseasProducerType(); overseasProducer.overseasContact = overseasContact; authorisedRepresentativeType authorisedRepresentative = new authorisedRepresentativeType(); authorisedRepresentative.overseasProducer = overseasProducer; producerType producer = new producerType(); producer.authorisedRepresentative = authorisedRepresentative; // Act RuleResult result = rule.Evaluate(producer); // Assert Assert.Equal(false, result.IsValid); Assert.Equal(ErrorLevel.Error, result.ErrorLevel); }
public async void SetAuthorisedRepresentative_WithRepresentativeOverseasProducer_ReturnsOverseasProducerWithName() { var authorisedRepresentative = new authorisedRepresentativeType() { overseasProducer = new overseasProducerType() { overseasProducerName = "Test overseas producer" } }; var builder = new GenerateFromXmlBuilder(); var result = await builder.Build().SetAuthorisedRepresentative(authorisedRepresentative); Assert.Equal("Test overseas producer", authorisedRepresentative.overseasProducer.overseasProducerName); Assert.Null(authorisedRepresentative.overseasProducer.overseasContact); }
public void Evaluate_ProducerHasNoOverseasProducer_Passes() { // Arrange EnsureAnOverseasProducerIsNotBasedInTheUK rule = new EnsureAnOverseasProducerIsNotBasedInTheUK(); authorisedRepresentativeType authorisedRepresentative = new authorisedRepresentativeType(); authorisedRepresentative.overseasProducer = null; producerType producer = new producerType(); producer.authorisedRepresentative = authorisedRepresentative; // Act RuleResult result = rule.Evaluate(producer); // Assert Assert.Equal(true, result.IsValid); }
public async Task <AuthorisedRepresentative> SetAuthorisedRepresentative(authorisedRepresentativeType representative) { AuthorisedRepresentative result = null; if (representative != null && representative.overseasProducer != null) { ProducerContact contact = null; if (representative.overseasProducer.overseasContact != null) { contact = await GetProducerContact(representative.overseasProducer.overseasContact); } result = new AuthorisedRepresentative(representative.overseasProducer.overseasProducerName, contact); } return(result); }
public void Evaluate_ProducerHasNoOverseasProducer_Passes() { // Arrange EnsureAnOverseasProducerIsNotBasedInTheUK rule = new EnsureAnOverseasProducerIsNotBasedInTheUK(); authorisedRepresentativeType authorisedRepresentative = new authorisedRepresentativeType(); authorisedRepresentative.overseasProducer = null; producerType producer = new producerType(); producer.authorisedRepresentative = authorisedRepresentative; // Act RuleResult result = rule.Evaluate(producer); // Assert Assert.Equal(true, result.IsValid); }
private void InstantiateProducerParameters() { TradingName = "Test trading name"; scheme = A.Fake <Scheme>(); MemberUpload = new MemberUpload( A.Dummy <Guid>(), A.Dummy <string>(), A.Dummy <List <MemberUploadError> >(), A.Dummy <decimal>(), A.Dummy <int>(), scheme, A.Dummy <string>(), A.Dummy <string>(), A.Dummy <bool>()); ProducerCharges = new Dictionary <string, ProducerCharge>(); ProducerCharges.Add(TradingName, new ProducerCharge() { ChargeBandAmount = new ChargeBandAmount() }); GeneratedPrns = new Queue <string>(); A.CallTo(() => DataAccess.ComputePrns(A <int> ._)).Returns(GeneratedPrns); BrandNames = Enumerable.Empty <string>().ToArray(); SicCodes = Enumerable.Empty <string>().ToArray(); ProducerBusiness = new producerBusinessType() { correspondentForNotices = new optionalContactDetailsContainerType() { }, Item = new companyType() { registeredOffice = new contactDetailsContainerType() { contactDetails = new contactDetailsType() { address = new addressType() { country = countryType.UKENGLAND } } } } }; AuthorisedRepresentative = null; EEEPlacedOnMarketBandType = eeePlacedOnMarketBandType.Lessthan5TEEEplacedonmarket; SellingTechnique = sellingTechniqueType.Both; ObligationType = obligationTypeType.Both; AnnualTurnoverBandType = annualTurnoverBandType.Greaterthanonemillionpounds; CeaseDate = null; RegistrationNumber = "TestRegistrationNumber"; AnnualTurnover = 10; VatRegistered = false; Status = statusType.I; }
public void Evaluate_ProducerHasOverseasContactInFrance_Passes() { // Arrange EnsureAnOverseasProducerIsNotBasedInTheUK rule = new EnsureAnOverseasProducerIsNotBasedInTheUK(); addressType address = new addressType(); address.country = countryType.FRANCE; contactDetailsType overseasContact = new contactDetailsType(); overseasContact.address = address; overseasProducerType overseasProducer = new overseasProducerType(); overseasProducer.overseasContact = overseasContact; authorisedRepresentativeType authorisedRepresentative = new authorisedRepresentativeType(); authorisedRepresentative.overseasProducer = overseasProducer; producerType producer = new producerType(); producer.authorisedRepresentative = authorisedRepresentative; // Act RuleResult result = rule.Evaluate(producer); // Assert Assert.Equal(true, result.IsValid); }
public void Evaluate_ProducerHasOverseaseContactInEngland_FailsWithError() { // Arrange EnsureAnOverseasProducerIsNotBasedInTheUK rule = new EnsureAnOverseasProducerIsNotBasedInTheUK(); addressType address = new addressType(); address.country = countryType.UKENGLAND; contactDetailsType overseasContact = new contactDetailsType(); overseasContact.address = address; overseasProducerType overseasProducer = new overseasProducerType(); overseasProducer.overseasContact = overseasContact; authorisedRepresentativeType authorisedRepresentative = new authorisedRepresentativeType(); authorisedRepresentative.overseasProducer = overseasProducer; producerType producer = new producerType(); producer.authorisedRepresentative = authorisedRepresentative; // Act RuleResult result = rule.Evaluate(producer); // Assert Assert.Equal(false, result.IsValid); Assert.Equal(ErrorLevel.Error, result.ErrorLevel); }
private void InstantiateProducerParameters() { TradingName = "Test trading name"; scheme = A.Fake<Scheme>(); MemberUpload = new MemberUpload( A.Dummy<Guid>(), A.Dummy<string>(), A.Dummy<List<MemberUploadError>>(), A.Dummy<decimal>(), A.Dummy<int>(), scheme, A.Dummy<string>(), A.Dummy<string>()); ProducerCharges = new Dictionary<string, ProducerCharge>(); ProducerCharges.Add(TradingName, new ProducerCharge() { ChargeBandAmount = new ChargeBandAmount() }); GeneratedPrns = new Queue<string>(); A.CallTo(() => DataAccess.ComputePrns(A<int>._)).Returns(GeneratedPrns); BrandNames = Enumerable.Empty<string>().ToArray(); SicCodes = Enumerable.Empty<string>().ToArray(); ProducerBusiness = new producerBusinessType() { correspondentForNotices = new optionalContactDetailsContainerType() { }, Item = new companyType() { registeredOffice = new contactDetailsContainerType() { contactDetails = new contactDetailsType() { address = new addressType() { country = countryType.UKENGLAND } } } } }; AuthorisedRepresentative = null; EEEPlacedOnMarketBandType = eeePlacedOnMarketBandType.Lessthan5TEEEplacedonmarket; SellingTechnique = sellingTechniqueType.Both; ObligationType = obligationTypeType.Both; AnnualTurnoverBandType = annualTurnoverBandType.Greaterthanonemillionpounds; CeaseDate = null; RegistrationNumber = "TestRegistrationNumber"; AnnualTurnover = 10; VatRegistered = false; Status = statusType.I; }
public async void SetAuthorisedRepresentative_WithRepresentativeOverseasProducer_WithContact_ReturnsOverseasProducerWithContact() { string forename = "forename"; string surname = "surname"; var authorisedRepresentative = new authorisedRepresentativeType() { overseasProducer = new overseasProducerType() { overseasContact = new contactDetailsType() { address = new addressType() { country = countryType.UKENGLAND }, forename = forename, surname = surname } } }; var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.DataAccess.GetCountry(A<string>._)).Returns(new Country(Guid.NewGuid(), "BELARUS")); var result = await builder.Build().SetAuthorisedRepresentative(authorisedRepresentative); Assert.Equal(forename, authorisedRepresentative.overseasProducer.overseasContact.forename); Assert.Equal(surname, authorisedRepresentative.overseasProducer.overseasContact.surname); }
public async void SetAuthorisedRepresentative_WithRepresentativeOverseasProducer_ReturnsOverseasProducerWithName() { var authorisedRepresentative = new authorisedRepresentativeType() { overseasProducer = new overseasProducerType() { overseasProducerName = "Test overseas producer" } }; var builder = new GenerateFromXmlBuilder(); var result = await builder.Build().SetAuthorisedRepresentative(authorisedRepresentative); Assert.Equal("Test overseas producer", authorisedRepresentative.overseasProducer.overseasProducerName); Assert.Null(authorisedRepresentative.overseasProducer.overseasContact); }
public async Task<AuthorisedRepresentative> SetAuthorisedRepresentative(authorisedRepresentativeType representative) { AuthorisedRepresentative result = null; if (representative != null && representative.overseasProducer != null) { ProducerContact contact = null; if (representative.overseasProducer.overseasContact != null) { contact = await GetProducerContact(representative.overseasProducer.overseasContact); } result = new AuthorisedRepresentative(representative.overseasProducer.overseasProducerName, contact); } return result; }