Ejemplo n.º 1
0
        public void Equals_SameInstance_ReturnsTrue()
        {
            AuthorisedRepresentative authorisedRepresentative = new AuthorisedRepresentative(
                "1",
                null);

            Assert.Equal(authorisedRepresentative, authorisedRepresentative);
        }
        public void Equals_SameInstance_ReturnsTrue()
        {
            AuthorisedRepresentative authorisedRepresentative = new AuthorisedRepresentative(
                "1",
                null);

            Assert.Equal(authorisedRepresentative, authorisedRepresentative);
        }
Ejemplo n.º 3
0
        public void Equals_ObjectParameter_ReturnsFalse()
        {
            AuthorisedRepresentative authorisedRepresentative = new AuthorisedRepresentative(
                "1",
                null);

            Assert.NotEqual(authorisedRepresentative, new object());
        }
        public void Equals_ObjectParameter_ReturnsFalse()
        {
            AuthorisedRepresentative authorisedRepresentative = new AuthorisedRepresentative(
                "1",
                null);

            Assert.NotEqual(authorisedRepresentative, new object());
        }
Ejemplo n.º 5
0
            public static ProducerSubmission WithAuthorisedRepresentative(AuthorisedRepresentative authorisedRepresentative)
            {
                var builder = new ProducerBuilder();

                builder.authorisedRepresentative = authorisedRepresentative;

                return(builder.Build());
            }
Ejemplo n.º 6
0
        public void AuthorisedRepresentative_WithNoOverseasProducer_DoesntThrowException()
        {
            // Arrange

            // Act
            AuthorisedRepresentative result = new AuthorisedRepresentative("Name", null);

            // Assert
            // No exception thrown.
        }
Ejemplo n.º 7
0
        public void AuthorisedRepresentative_WithOverseasProducerNotBasedInUK_DoesntThrowException()
        {
            // Arrange
            ProducerContact contact = A.Fake <ProducerContact>();

            A.CallTo(() => contact.IsOverseas).Returns(true);

            // Act
            AuthorisedRepresentative result = new AuthorisedRepresentative("Name", contact);

            // Assert
            // No exception thrown.
        }
        public void Equals_AuthorisedRepresentativeWithSameDetails_ReturnsTrue()
        {
            ProducerContact contact = A.Dummy<ProducerContact>();
            A.CallTo(() => contact.IsOverseas).Returns(true);

            AuthorisedRepresentative authorisedRepresentative1 = new AuthorisedRepresentative(
                "1",
                contact);

            AuthorisedRepresentative authorisedRepresentative2 = new AuthorisedRepresentative(
                "1",
                contact);

            Assert.Equal(authorisedRepresentative1, authorisedRepresentative2);
        }
        public void Equals_AuthorisedRepresentativeWithDifferentName_ReturnsFalse()
        {
            ProducerContact contact = A.Fake<ProducerContact>();
            A.CallTo(() => contact.IsOverseas).Returns(true);

            AuthorisedRepresentative authorisedRepresentative1 = new AuthorisedRepresentative(
                "1",
                contact);

            AuthorisedRepresentative authorisedRepresentative2 = new AuthorisedRepresentative(
                "2",
                contact);

            Assert.NotEqual(authorisedRepresentative1, authorisedRepresentative2);
        }
Ejemplo n.º 10
0
        public void Equals_AuthorisedRepresentativeWithDifferentName_ReturnsFalse()
        {
            ProducerContact contact = A.Fake <ProducerContact>();

            A.CallTo(() => contact.IsOverseas).Returns(true);

            AuthorisedRepresentative authorisedRepresentative1 = new AuthorisedRepresentative(
                "1",
                contact);

            AuthorisedRepresentative authorisedRepresentative2 = new AuthorisedRepresentative(
                "2",
                contact);

            Assert.NotEqual(authorisedRepresentative1, authorisedRepresentative2);
        }
Ejemplo n.º 11
0
        public void Equals_AuthorisedRepresentativeWithSameDetails_ReturnsTrue()
        {
            ProducerContact contact = A.Dummy <ProducerContact>();

            A.CallTo(() => contact.IsOverseas).Returns(true);

            AuthorisedRepresentative authorisedRepresentative1 = new AuthorisedRepresentative(
                "1",
                contact);

            AuthorisedRepresentative authorisedRepresentative2 = new AuthorisedRepresentative(
                "1",
                contact);

            Assert.Equal(authorisedRepresentative1, authorisedRepresentative2);
        }
Ejemplo n.º 12
0
        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 async Task Execute_WithAuthorisedRepresentative_ReturnsOverseasProducer()
        {
            using (DatabaseWrapper db = new DatabaseWrapper())
            {
                // Arrange
                ModelHelper helper = new ModelHelper(db.Model);

                Scheme scheme1 = helper.CreateScheme();

                MemberUpload memberUpload1 = helper.CreateMemberUpload(scheme1);
                memberUpload1.ComplianceYear = 2016;
                memberUpload1.IsSubmitted    = true;
                memberUpload1.SubmittedDate  = new DateTime(2015, 1, 1);

                ProducerSubmission producer1 = helper.CreateProducerAsCompany(memberUpload1, "WEE/11AAAA11");

                AuthorisedRepresentative authorisedRepresentative = new AuthorisedRepresentative()
                {
                    Id = new Guid("620E71A6-0E74-47AF-B82F-97BA64083E37"),
                    OverseasProducerName = "Overseas Producer Name",
                };
                db.Model.AuthorisedRepresentatives.Add(authorisedRepresentative);

                producer1.AuthorisedRepresentative = authorisedRepresentative;

                db.Model.SaveChanges();

                // Act
                List <ProducerCsvData> results =
                    await db.StoredProcedures.SpgCSVDataByOrganisationIdAndComplianceYear(scheme1.OrganisationId, 2016);

                // Assert
                Assert.NotNull(results);
                Assert.Equal(1, results.Count);

                ProducerCsvData result = results[0];

                Assert.Equal("No", result.AuthorisedRepresentative);
                Assert.Equal("Overseas Producer Name", result.OverseasProducer);
            }
        }
Ejemplo n.º 14
0
        public void Equals_AuthorisedRepresentativeWithDifferentProducerContact_ReturnsFalse()
        {
            ProducerContact contact1 = A.Fake <ProducerContact>();

            A.CallTo(() => contact1.IsOverseas).Returns(true);
            A.CallTo(() => contact1.Equals(A <ProducerContact> ._)).Returns(false);

            ProducerContact contact2 = A.Fake <ProducerContact>();

            A.CallTo(() => contact2.IsOverseas).Returns(true);
            A.CallTo(() => contact2.Equals(A <ProducerContact> ._)).Returns(false);

            AuthorisedRepresentative authorisedRepresentative1 = new AuthorisedRepresentative(
                "1",
                contact1);

            AuthorisedRepresentative authorisedRepresentative2 = new AuthorisedRepresentative(
                "1",
                contact2);

            Assert.NotEqual(authorisedRepresentative1, authorisedRepresentative2);
        }
        public void AuthorisedRepresentative_WithOverseasProducerNotBasedInUK_DoesntThrowException()
        {
            // Arrange
            ProducerContact contact = A.Fake<ProducerContact>();
            A.CallTo(() => contact.IsOverseas).Returns(true);

            // Act
            AuthorisedRepresentative result = new AuthorisedRepresentative("Name", contact);

            // Assert
            // No exception thrown.
        }
Ejemplo n.º 16
0
 public override bool Equals(AuthorisedRepresentative other)
 {
     return(false);
 }
            public static ProducerSubmission WithAuthorisedRepresentative(AuthorisedRepresentative authorisedRepresentative)
            {
                var builder = new ProducerBuilder();
                builder.authorisedRepresentative = authorisedRepresentative;

                return builder.Build();
            }
 public override bool Equals(AuthorisedRepresentative other)
 {
     return false;
 }
        public void Equals_AuthorisedRepresentativeWithDifferentProducerContact_ReturnsFalse()
        {
            ProducerContact contact1 = A.Fake<ProducerContact>();
            A.CallTo(() => contact1.IsOverseas).Returns(true);
            A.CallTo(() => contact1.Equals(A<ProducerContact>._)).Returns(false);

            ProducerContact contact2 = A.Fake<ProducerContact>();
            A.CallTo(() => contact2.IsOverseas).Returns(true);
            A.CallTo(() => contact2.Equals(A<ProducerContact>._)).Returns(false);

            AuthorisedRepresentative authorisedRepresentative1 = new AuthorisedRepresentative(
                "1",
                contact1);

            AuthorisedRepresentative authorisedRepresentative2 = new AuthorisedRepresentative(
                "1",
                contact2);

            Assert.NotEqual(authorisedRepresentative1, authorisedRepresentative2);
        }
Ejemplo n.º 20
0
        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;
        }
Ejemplo n.º 21
0
        public async Task <IEnumerable <ProducerSubmission> > GenerateProducerData(schemeType scheme, MemberUpload memberUpload, Dictionary <string, ProducerCharge> producerCharges)
        {
            if (memberUpload.ComplianceYear == null)
            {
                string errorMessage = "Producers cannot be generated for a member upload "
                                      + "that does not have a compliance year.";
                throw new InvalidOperationException(errorMessage);
            }

            List <ProducerSubmission> producers = new List <ProducerSubmission>();

            int            numberOfPrnsNeeded = scheme.producerList.Count(p => p.status == statusType.I);
            Queue <string> generatedPrns      = await dataAccess.ComputePrns(numberOfPrnsNeeded);

            foreach (producerType producerData in scheme.producerList)
            {
                var producerName = producerData.GetProducerName();

                if (producerCharges == null)
                {
                    throw new ApplicationException("No charges have been supplied");
                }
                if (!producerCharges.ContainsKey(producerName))
                {
                    throw new ApplicationException(string.Format("No charges have been supplied for the {0}.", producerName));
                }
                var chargeBandAmount = producerCharges[producerName].ChargeBandAmount;
                var chargeThisUpdate = producerCharges[producerName].Amount;

                List <BrandName> brandNames = producerData.producerBrandNames.Select(name => new BrandName(name)).ToList();

                List <SICCode> codes = producerData.SICCodeList.Select(name => new SICCode(name)).ToList();

                ProducerBusiness producerBusiness = await SetProducerBusiness(producerData.producerBusiness);

                AuthorisedRepresentative authorisedRepresentative = await SetAuthorisedRepresentative(producerData.authorisedRepresentative);

                EEEPlacedOnMarketBandType eeebandType = Enumeration.FromValue <EEEPlacedOnMarketBandType>((int)producerData.eeePlacedOnMarketBand);

                SellingTechniqueType sellingTechniqueType = Enumeration.FromValue <SellingTechniqueType>((int)producerData.sellingTechnique);

                ObligationType obligationType = producerData.obligationType.ToDomainObligationType();

                AnnualTurnOverBandType annualturnoverType = Enumeration.FromValue <AnnualTurnOverBandType>((int)producerData.annualTurnoverBand);

                StatusType status = Enumeration.FromValue <StatusType>((int)producerData.status);

                DateTime?ceaseDate = null;
                if (producerData.ceaseToExistDateSpecified)
                {
                    ceaseDate = producerData.ceaseToExistDate;
                }

                RegisteredProducer registeredProducer = null;

                string producerRegistrationNo;
                switch (producerData.status)
                {
                case statusType.I:
                    producerRegistrationNo = generatedPrns.Dequeue();
                    break;

                case statusType.A:
                    producerRegistrationNo = producerData.registrationNo;

                    await EnsureProducerRegistrationNumberExists(producerRegistrationNo);

                    registeredProducer = await dataAccess.FetchRegisteredProducerOrDefault(
                        producerRegistrationNo,
                        memberUpload.ComplianceYear.Value,
                        memberUpload.Scheme.Id);

                    break;

                default:
                    throw new NotSupportedException();
                }

                if (registeredProducer == null)
                {
                    registeredProducer = new RegisteredProducer(
                        producerRegistrationNo,
                        memberUpload.ComplianceYear.Value,
                        memberUpload.Scheme);
                }

                ProducerSubmission producer = new ProducerSubmission(
                    registeredProducer,
                    memberUpload,
                    producerBusiness,
                    authorisedRepresentative,
                    SystemTime.UtcNow,
                    producerData.annualTurnover,
                    producerData.VATRegistered,
                    ceaseDate,
                    producerData.tradingName,
                    eeebandType,
                    sellingTechniqueType,
                    obligationType,
                    annualturnoverType,
                    brandNames,
                    codes,
                    chargeBandAmount,
                    chargeThisUpdate,
                    status);

                // modify producer data
                switch (producerData.status)
                {
                case statusType.A:

                    if (registeredProducer.CurrentSubmission == null)
                    {
                        producers.Add(producer);
                    }
                    else
                    {
                        if (!registeredProducer.CurrentSubmission.Equals(producer))
                        {
                            producers.Add(producer);
                        }
                        else
                        {
                            /*
                             * The producer's details are the same as the current submission for this
                             * registration so we don't need to update them.
                             */
                        }
                    }
                    break;

                case statusType.I:
                    producers.Add(producer);
                    break;
                }
            }

            return(producers);
        }
        public void AuthorisedRepresentative_WithNoOverseasProducer_DoesntThrowException()
        {
            // Arrange

            // Act
            AuthorisedRepresentative result = new AuthorisedRepresentative("Name", null);

            // Assert
            // No exception thrown.
        }