示例#1
0
        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);
        }
示例#2
0
        public async Task <ProducerBusiness> SetProducerBusiness(producerBusinessType producerBusiness)
        {
            object          item = producerBusiness.Item;
            ProducerContact correspondentForNoticeContact = null;

            if (producerBusiness.correspondentForNotices.contactDetails != null)
            {
                correspondentForNoticeContact =
                    await GetProducerContact(producerBusiness.correspondentForNotices.contactDetails);
            }

            Company     company     = null;
            Partnership partnership = null;

            if (item is companyType)
            {
                companyType     companyitem = (companyType)item;
                ProducerContact contact     = await GetProducerContact(companyitem.registeredOffice.contactDetails);

                company = new Company(companyitem.companyName, companyitem.companyNumber, contact);
            }
            else if (item is partnershipType)
            {
                partnershipType partnershipItem = (partnershipType)item;
                string          partnershipName = partnershipItem.partnershipName;

                List <string>   partnersList = partnershipItem.partnershipList.ToList();
                List <Partner>  partners     = partnersList.Select(name => new Partner(name)).ToList();
                ProducerContact contact      = await GetProducerContact(partnershipItem.principalPlaceOfBusiness.contactDetails);

                partnership = new Partnership(partnershipName, contact, partners);
            }

            return(new ProducerBusiness(company, partnership, correspondentForNoticeContact));
        }
示例#3
0
        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));
        }
示例#4
0
        private static producerType SetUpProducer(countryType countryType, eeePlacedOnMarketBandType eeePlacedOnMarketBandType, annualTurnoverBandType annualTurnoverBandType, bool vatRegistered)
        {
            var producerCompany = new companyType()
            {
                companyName      = "Test company",
                companyNumber    = "Test CRN",
                registeredOffice = new contactDetailsContainerType()
                {
                    contactDetails = new contactDetailsType()
                    {
                        address = new addressType()
                        {
                            country = countryType
                        }
                    }
                }
            };

            var producerBusiness = new producerBusinessType()
            {
                Item = producerCompany
            };

            var producer = new producerType
            {
                annualTurnoverBand    = annualTurnoverBandType,
                VATRegistered         = vatRegistered,
                eeePlacedOnMarketBand = eeePlacedOnMarketBandType,
                producerBusiness      = producerBusiness
            };

            return(producer);
        }
示例#5
0
        private static producerType SetRegisteredOfficeOrPPoBDetails(bool hasPartnership)
        {
            producerBusinessType producerBusiness = null;

            var contactDetailsInfo = new contactDetailsContainerType()
            {
                contactDetails = new contactDetailsType()
                {
                    address = new addressType()
                    {
                        country = countryType.UKENGLAND
                    }
                }
            };

            if (hasPartnership)
            {
                var producerPartnership = new partnershipType()
                {
                    partnershipName          = "MiddleEarth",
                    principalPlaceOfBusiness = contactDetailsInfo
                };

                producerBusiness = new producerBusinessType()
                {
                    Item = producerPartnership
                };
            }
            else
            {
                var producerCompany = new companyType()
                {
                    companyName      = "Rivendell",
                    registeredOffice = contactDetailsInfo
                };

                producerBusiness = new producerBusinessType()
                {
                    Item = producerCompany
                };
            }

            var producer = new producerType
            {
                producerBusiness = producerBusiness
            };

            return(producer);
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
            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;
            }
            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 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 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_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_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 Task<ProducerBusiness> SetProducerBusiness(producerBusinessType producerBusiness)
        {
            object item = producerBusiness.Item;
            ProducerContact correspondentForNoticeContact = null;
            if (producerBusiness.correspondentForNotices.contactDetails != null)
            {
                correspondentForNoticeContact =
                    await GetProducerContact(producerBusiness.correspondentForNotices.contactDetails);
            }

            Company company = null;
            Partnership partnership = null;
            if (item is companyType)
            {
                companyType companyitem = (companyType)item;
                ProducerContact contact = await GetProducerContact(companyitem.registeredOffice.contactDetails);
                company = new Company(companyitem.companyName, companyitem.companyNumber, contact);
            }
            else if (item is partnershipType)
            {
                partnershipType partnershipItem = (partnershipType)item;
                string partnershipName = partnershipItem.partnershipName;

                List<string> partnersList = partnershipItem.partnershipList.ToList();
                List<Partner> partners = partnersList.Select(name => new Partner(name)).ToList();
                ProducerContact contact = await GetProducerContact(partnershipItem.principalPlaceOfBusiness.contactDetails);
                partnership = new Partnership(partnershipName, contact, partners);
            }

            return new ProducerBusiness(company, partnership, correspondentForNoticeContact);
        }