public async void SetProducerBusiness_WithCorrespondentForNotices_ReturnsCorrespondentForNoticesDetails() { string forename = "forename"; string surname = "surname"; var business = new producerBusinessType() { correspondentForNotices = new optionalContactDetailsContainerType() { contactDetails = new contactDetailsType() { address = new addressType() { country = countryType.UKENGLAND }, forename = forename, surname = surname } } }; var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.DataAccess.GetCountry(A <string> ._)).Returns((Country)null); var result = await builder.Build().SetProducerBusiness(business); Assert.NotNull(result.CorrespondentForNoticesContact); Assert.Equal(forename, result.CorrespondentForNoticesContact.ForeName); Assert.Equal(surname, result.CorrespondentForNoticesContact.SurName); }
public void GetCountryName_RetrievesCountryNameFromAttributeIfPresent(countryType country, string countryName) { var builder = new GenerateFromXmlBuilder(); var result = builder.Build().GetCountryName(country); Assert.Equal(countryName, result); }
public async void SetProducerBusiness_WithPartnership_ReturnsPartnershipWithPartnersDetails() { var partners = new[] { "P1", "P3" }; var business = new producerBusinessType() { correspondentForNotices = new optionalContactDetailsContainerType(), Item = new partnershipType() { partnershipList = partners, principalPlaceOfBusiness = new contactDetailsContainerType() { contactDetails = new contactDetailsType() { address = new addressType() { country = countryType.UKENGLAND } } } } }; var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.DataAccess.GetCountry(A <string> ._)).Returns((Country)null); var result = await builder.Build().SetProducerBusiness(business); Assert.Collection(result.Partnership.PartnersList, r1 => Assert.Equal("P1", r1.Name), r1 => Assert.Equal("P3", r1.Name)); }
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_WithNullRepresentative_ReturnsNull() { var builder = new GenerateFromXmlBuilder(); var result = await builder.Build().SetAuthorisedRepresentative(null); Assert.Null(result); }
public async void SetAuthorisedRepresentative_WithNullRepresentativeOverseasProducer_ReturnsNull() { var builder = new GenerateFromXmlBuilder(); var result = await builder.Build().SetAuthorisedRepresentative(new authorisedRepresentativeType()); Assert.Null(result); }
public void GenerateDataReturns_SchemaValidatorHasErrors_ShouldReturnErrors() { var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.SchemaValidator.Validate(A <byte[]> ._, A <string> ._, A <XNamespace> ._, A <string> ._)) .Returns(new List <XmlValidationError> { new XmlValidationError(Core.Shared.ErrorLevel.Error, XmlErrorType.Schema, "An error occurred") }); var result = builder.Build().GenerateDataReturns <SchemeReturn>(new ProcessDataReturnXmlFile(A.Dummy <Guid>(), A.Dummy <byte[]>(), A.Dummy <string>())); Assert.NotEmpty(result.SchemaErrors); }
public void GenerateMemberUpload_NullSchemaErrors_ComplianceYearObtained() { var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.XmlConverter.Deserialize<schemeType>(A<XDocument>._)) .Returns(new schemeType { complianceYear = "2015" }); var message = new ProcessXmlFile(Guid.NewGuid(), new byte[1], "File name"); var generateFromXml = builder.Build(); var result = generateFromXml.GenerateMemberUpload(message, null, 2015, A.Fake<Scheme>()); Assert.NotNull(result.ComplianceYear); Assert.Equal(2015, result.ComplianceYear.Value); }
public void GenerateDataReturns_SchemaValidatorHasErrors_ShouldReturnErrors() { var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.SchemaValidator.Validate(A<byte[]>._, A<string>._, A<XNamespace>._, A<string>._)) .Returns(new List<XmlValidationError> { new XmlValidationError(Core.Shared.ErrorLevel.Error, XmlErrorType.Schema, "An error occurred") }); var result = builder.Build().GenerateDataReturns<SchemeReturn>(new ProcessDataReturnXmlFile(A.Dummy<Guid>(), A.Dummy<byte[]>(), A.Dummy<string>())); Assert.NotEmpty(result.SchemaErrors); }
public void GenerateDataReturns_SchemaValidatorHasNoErrors_DeserializationException_ShouldReturnError() { var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.SchemaValidator.Validate(A<byte[]>._, string.Empty, A<XNamespace>._, A<string>._)) .Returns(new List<XmlValidationError>()); A.CallTo(() => builder.XmlConverter.Deserialize<SchemeReturn>(A<XDocument>._)) .Throws(new XmlDeserializationFailureException(new Exception("Test exception"))); var result = builder.Build().GenerateDataReturns<SchemeReturn>(new ProcessDataReturnXmlFile(A.Dummy<Guid>(), A.Dummy<byte[]>(), A.Dummy<string>())); Assert.NotEmpty(result.SchemaErrors); Assert.Equal(1, result.SchemaErrors.Count); }
public void GenerateDataReturns_SchemaValidatorHasNoErrors_DeserializationException_ShouldReturnError() { var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.SchemaValidator.Validate(A <byte[]> ._, string.Empty, A <XNamespace> ._, A <string> ._)) .Returns(new List <XmlValidationError>()); A.CallTo(() => builder.XmlConverter.Deserialize <SchemeReturn>(A <XDocument> ._)) .Throws(new XmlDeserializationFailureException(new Exception("Test exception"))); var result = builder.Build().GenerateDataReturns <SchemeReturn>(new ProcessDataReturnXmlFile(A.Dummy <Guid>(), A.Dummy <byte[]>(), A.Dummy <string>())); Assert.NotEmpty(result.SchemaErrors); Assert.Equal(1, result.SchemaErrors.Count); }
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 GenerateDataReturns_ReturnsExpectedDeserialisedType() { var schemeReturn = new SchemeReturn(); var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.SchemaValidator.Validate(A<byte[]>._, string.Empty, A<XNamespace>._, A<string>._)) .Returns(new List<XmlValidationError>()); A.CallTo(() => builder.XmlConverter.Deserialize<SchemeReturn>(A<XDocument>._)) .Returns(schemeReturn); var result = builder.Build().GenerateDataReturns<SchemeReturn>(new ProcessDataReturnXmlFile(A.Dummy<Guid>(), A.Dummy<byte[]>(), A.Dummy<string>())); Assert.IsType<SchemeReturn>(result.DeserialisedType); Assert.Equal(schemeReturn, result.DeserialisedType); }
public void GenerateDataReturns_ReturnsExpectedDeserialisedType() { var schemeReturn = new SchemeReturn(); var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.SchemaValidator.Validate(A <byte[]> ._, string.Empty, A <XNamespace> ._, A <string> ._)) .Returns(new List <XmlValidationError>()); A.CallTo(() => builder.XmlConverter.Deserialize <SchemeReturn>(A <XDocument> ._)) .Returns(schemeReturn); var result = builder.Build().GenerateDataReturns <SchemeReturn>(new ProcessDataReturnXmlFile(A.Dummy <Guid>(), A.Dummy <byte[]>(), A.Dummy <string>())); Assert.IsType <SchemeReturn>(result.DeserialisedType); Assert.Equal(schemeReturn, result.DeserialisedType); }
public void GenerateMemberUpload_NullSchemaErrors_ComplianceYearObtained() { var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.XmlConverter.Deserialize <schemeType>(A <XDocument> ._)) .Returns(new schemeType { complianceYear = "2015" }); var message = new ProcessXmlFile(Guid.NewGuid(), new byte[1], "File name"); var generateFromXml = builder.Build(); var result = generateFromXml.GenerateMemberUpload(message, null, 2015, A.Fake <Scheme>(), false); Assert.NotNull(result.ComplianceYear); Assert.Equal(2015, result.ComplianceYear.Value); }
public async void GetProducerContact_ReturnsContactWithCorrectAddressDetails() { string primary = "Primary"; string secondary = "Secondary"; string street = "Street"; string locality = "Locality"; string admimistrativeArea = "Area"; string postCode = "WE3"; countryType country = countryType.UKENGLAND; string countryName = "UK - ENGLAND"; var contact = new contactDetailsType() { address = new addressType() { primaryName = primary, secondaryName = secondary, streetName = street, locality = locality, administrativeArea = admimistrativeArea, Item = postCode, country = country } }; var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.DataAccess.GetCountry(A <string> ._)).Returns(new Country(Guid.NewGuid(), countryName)); var result = await builder.Build().GetProducerContact(contact); var resultAddress = result.Address; Assert.Equal(primary, resultAddress.PrimaryName); Assert.Equal(secondary, resultAddress.SecondaryName); Assert.Equal(street, resultAddress.Street); Assert.Equal(locality, resultAddress.Locality); Assert.Equal(admimistrativeArea, resultAddress.AdministrativeArea); Assert.Equal(postCode, resultAddress.PostCode); Assert.Equal(countryName, resultAddress.Country.Name); }
public async void SetProducerBusiness_WithCompanyBusiness_ReturnsBusinessWithCompanyDetails() { string companyName = "Company name"; string companyRegistration = "CRN1234"; string town = "Town"; var business = new producerBusinessType() { correspondentForNotices = new optionalContactDetailsContainerType(), Item = new companyType() { companyName = companyName, companyNumber = companyRegistration, registeredOffice = new contactDetailsContainerType() { contactDetails = new contactDetailsType() { address = new addressType() { town = town, country = countryType.UKENGLAND } } } } }; var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.DataAccess.GetCountry(A <string> ._)).Returns((Country)null); var result = await builder.Build().SetProducerBusiness(business); Assert.NotNull(result.CompanyDetails); Assert.Null(result.Partnership); Assert.Equal(companyName, result.CompanyDetails.Name); Assert.Equal(companyRegistration, result.CompanyDetails.CompanyNumber); Assert.Equal(town, result.CompanyDetails.RegisteredOfficeContact.Address.Town); }
public async void SetProducerBusiness_WithPartnership_ReturnsBusinessWithPartnershipDetails() { var partnershipName = "Company name"; var partners = new[] { "P1" }; string town = "Town"; var business = new producerBusinessType() { correspondentForNotices = new optionalContactDetailsContainerType(), Item = new partnershipType() { partnershipName = partnershipName, partnershipList = partners, principalPlaceOfBusiness = new contactDetailsContainerType() { contactDetails = new contactDetailsType() { address = new addressType() { town = town, country = countryType.UKENGLAND } } } } }; var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.DataAccess.GetCountry(A <string> ._)).Returns((Country)null); var result = await builder.Build().SetProducerBusiness(business); Assert.NotNull(result.Partnership); Assert.Null(result.CompanyDetails); Assert.Equal(partnershipName, result.Partnership.Name); Assert.Equal(town, result.Partnership.PrincipalPlaceOfBusiness.Address.Town); }
public void GenerateMemberUpload_ReturnsNewMemberUpload_WithCorrectValues() { var message = new ProcessXmlFile( new Guid("4CAD6CA3-E4E7-4D1A-BAAB-8C454EECF109"), new byte[1], "File name"); Scheme scheme = A.Dummy <Scheme>(); var errors = new List <MemberUploadError> { new MemberUploadError(ErrorLevel.Error, UploadErrorType.Business, "Some schema error") }; var builder = new GenerateFromXmlBuilder(); string xml = "Test xml contents"; A.CallTo(() => builder.XmlConverter.XmlToUtf8String(A <byte[]> ._)).Returns(xml); schemeType xmlScheme = new schemeType() { complianceYear = "2015" }; A.CallTo(() => builder.XmlConverter.Deserialize <schemeType>(A <XDocument> ._)).Returns(xmlScheme); var result = builder.Build().GenerateMemberUpload(message, errors, 1000, scheme, false); Assert.Equal(new Guid("4CAD6CA3-E4E7-4D1A-BAAB-8C454EECF109"), result.OrganisationId); Assert.Equal(xml, result.RawData.Data); Assert.Equal(errors, result.Errors); Assert.Equal(1000, result.TotalCharges); Assert.Equal(2015, result.ComplianceYear); Assert.Equal(scheme, result.Scheme); Assert.Equal("File name", result.FileName); }
public async void GetProducerContact_ReturnsContactWithIndividualDetails() { string title = "title"; string forename = "forename"; string surname = "surname"; string landline = "987654"; string mobile = "12345"; string fax = "564"; string email = "[email protected]"; var contact = new contactDetailsType() { address = new addressType(), title = title, forename = forename, surname = surname, phoneLandLine = landline, phoneMobile = mobile, fax = fax, email = email }; var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.DataAccess.GetCountry(A <string> ._)).Returns(new Country(Guid.NewGuid(), email)); var result = await builder.Build().GetProducerContact(contact); Assert.Equal(title, result.Title); Assert.Equal(forename, result.ForeName); Assert.Equal(surname, result.SurName); Assert.Equal(landline, result.Telephone); Assert.Equal(mobile, result.Mobile); Assert.Equal(fax, result.Fax); Assert.Equal(email, result.Email); }
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 GetCountryName_RetrievesCountryNameFromAttributeIfPresent(countryType country, string countryName) { var builder = new GenerateFromXmlBuilder(); var result = builder.Build().GetCountryName(country); Assert.Equal(countryName, result); }
public async void GetProducerContact_ReturnsContactWithCorrectAddressDetails() { string primary = "Primary"; string secondary = "Secondary"; string street = "Street"; string locality = "Locality"; string admimistrativeArea = "Area"; string postCode = "WE3"; countryType country = countryType.UKENGLAND; string countryName = "UK - ENGLAND"; var contact = new contactDetailsType() { address = new addressType() { primaryName = primary, secondaryName = secondary, streetName = street, locality = locality, administrativeArea = admimistrativeArea, Item = postCode, country = country } }; var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.DataAccess.GetCountry(A<string>._)).Returns(new Country(Guid.NewGuid(), countryName)); var result = await builder.Build().GetProducerContact(contact); var resultAddress = result.Address; Assert.Equal(primary, resultAddress.PrimaryName); Assert.Equal(secondary, resultAddress.SecondaryName); Assert.Equal(street, resultAddress.Street); Assert.Equal(locality, resultAddress.Locality); Assert.Equal(admimistrativeArea, resultAddress.AdministrativeArea); Assert.Equal(postCode, resultAddress.PostCode); Assert.Equal(countryName, resultAddress.Country.Name); }
public async void GetProducerContact_ReturnsContactWithIndividualDetails() { string title = "title"; string forename = "forename"; string surname = "surname"; string landline = "987654"; string mobile = "12345"; string fax = "564"; string email = "[email protected]"; var contact = new contactDetailsType() { address = new addressType(), title = title, forename = forename, surname = surname, phoneLandLine = landline, phoneMobile = mobile, fax = fax, email = email }; var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.DataAccess.GetCountry(A<string>._)).Returns(new Country(Guid.NewGuid(), email)); var result = await builder.Build().GetProducerContact(contact); Assert.Equal(title, result.Title); Assert.Equal(forename, result.ForeName); Assert.Equal(surname, result.SurName); Assert.Equal(landline, result.Telephone); Assert.Equal(mobile, result.Mobile); Assert.Equal(fax, result.Fax); Assert.Equal(email, result.Email); }
public async void SetProducerBusiness_WithCompanyBusiness_ReturnsBusinessWithCompanyDetails() { string companyName = "Company name"; string companyRegistration = "CRN1234"; string town = "Town"; var business = new producerBusinessType() { correspondentForNotices = new optionalContactDetailsContainerType(), Item = new companyType() { companyName = companyName, companyNumber = companyRegistration, registeredOffice = new contactDetailsContainerType() { contactDetails = new contactDetailsType() { address = new addressType() { town = town, country = countryType.UKENGLAND } } } } }; var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.DataAccess.GetCountry(A<string>._)).Returns((Country)null); var result = await builder.Build().SetProducerBusiness(business); Assert.NotNull(result.CompanyDetails); Assert.Null(result.Partnership); Assert.Equal(companyName, result.CompanyDetails.Name); Assert.Equal(companyRegistration, result.CompanyDetails.CompanyNumber); Assert.Equal(town, result.CompanyDetails.RegisteredOfficeContact.Address.Town); }
public async void SetProducerBusiness_WithPartnership_ReturnsBusinessWithPartnershipDetails() { var partnershipName = "Company name"; var partners = new[] { "P1" }; string town = "Town"; var business = new producerBusinessType() { correspondentForNotices = new optionalContactDetailsContainerType(), Item = new partnershipType() { partnershipName = partnershipName, partnershipList = partners, principalPlaceOfBusiness = new contactDetailsContainerType() { contactDetails = new contactDetailsType() { address = new addressType() { town = town, country = countryType.UKENGLAND } } } } }; var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.DataAccess.GetCountry(A<string>._)).Returns((Country)null); var result = await builder.Build().SetProducerBusiness(business); Assert.NotNull(result.Partnership); Assert.Null(result.CompanyDetails); Assert.Equal(partnershipName, result.Partnership.Name); Assert.Equal(town, result.Partnership.PrincipalPlaceOfBusiness.Address.Town); }
public async void SetProducerBusiness_WithPartnership_ReturnsPartnershipWithPartnersDetails() { var partners = new[] { "P1", "P3" }; var business = new producerBusinessType() { correspondentForNotices = new optionalContactDetailsContainerType(), Item = new partnershipType() { partnershipList = partners, principalPlaceOfBusiness = new contactDetailsContainerType() { contactDetails = new contactDetailsType() { address = new addressType() { country = countryType.UKENGLAND } } } } }; var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.DataAccess.GetCountry(A<string>._)).Returns((Country)null); var result = await builder.Build().SetProducerBusiness(business); Assert.Collection(result.Partnership.PartnersList, r1 => Assert.Equal("P1", r1.Name), r1 => Assert.Equal("P3", r1.Name)); }
public async void SetProducerBusiness_WithCorrespondentForNotices_ReturnsCorrespondentForNoticesDetails() { string forename = "forename"; string surname = "surname"; var business = new producerBusinessType() { correspondentForNotices = new optionalContactDetailsContainerType() { contactDetails = new contactDetailsType() { address = new addressType() { country = countryType.UKENGLAND }, forename = forename, surname = surname } } }; var builder = new GenerateFromXmlBuilder(); A.CallTo(() => builder.DataAccess.GetCountry(A<string>._)).Returns((Country)null); var result = await builder.Build().SetProducerBusiness(business); Assert.NotNull(result.CorrespondentForNoticesContact); Assert.Equal(forename, result.CorrespondentForNoticesContact.ForeName); Assert.Equal(surname, result.CorrespondentForNoticesContact.SurName); }
public async void SetAuthorisedRepresentative_WithNullRepresentative_ReturnsNull() { var builder = new GenerateFromXmlBuilder(); var result = await builder.Build().SetAuthorisedRepresentative(null); Assert.Null(result); }
public async void SetAuthorisedRepresentative_WithNullRepresentativeOverseasProducer_ReturnsNull() { var builder = new GenerateFromXmlBuilder(); var result = await builder.Build().SetAuthorisedRepresentative(new authorisedRepresentativeType()); Assert.Null(result); }
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 GenerateMemberUpload_ReturnsNewMemberUpload_WithCorrectValues() { var message = new ProcessXmlFile( new Guid("4CAD6CA3-E4E7-4D1A-BAAB-8C454EECF109"), new byte[1], "File name"); Scheme scheme = A.Dummy<Scheme>(); var errors = new List<MemberUploadError> { new MemberUploadError(ErrorLevel.Error, UploadErrorType.Business, "Some schema error") }; var builder = new GenerateFromXmlBuilder(); string xml = "Test xml contents"; A.CallTo(() => builder.XmlConverter.XmlToUtf8String(A<byte[]>._)).Returns(xml); schemeType xmlScheme = new schemeType() { complianceYear = "2015" }; A.CallTo(() => builder.XmlConverter.Deserialize<schemeType>(A<XDocument>._)).Returns(xmlScheme); var result = builder.Build().GenerateMemberUpload(message, errors, 1000, scheme); Assert.Equal(new Guid("4CAD6CA3-E4E7-4D1A-BAAB-8C454EECF109"), result.OrganisationId); Assert.Equal(xml, result.RawData.Data); Assert.Equal(errors, result.Errors); Assert.Equal(1000, result.TotalCharges); Assert.Equal(2015, result.ComplianceYear); Assert.Equal(scheme, result.Scheme); Assert.Equal("File name", result.FileName); }