ProducerRegisteredMatchesComplianceYearAndObligationType_ButRegistrationNumberIsNullOrEmpty_ValidationSucceeds
            (string registrationNumber)
        {
            const string             complianceYear = "2016";
            const obligationTypeType obligationType = obligationTypeType.B2B;

            A.CallTo(() => producerQuerySet.GetProducerForOtherSchemeAndObligationType(A <string> ._, A <string> ._, A <Guid> ._, A <ObligationType> ._))
            .Returns(FakeProducer.Create(obligationType.ToDomainObligationType(), registrationNumber));

            producerType producer = new producerType()
            {
                tradingName      = "Test Trader",
                obligationType   = obligationType,
                producerBusiness = new producerBusinessType
                {
                    Item = new partnershipType
                    {
                        partnershipName = "New Producer Name"
                    }
                }
            };

            schemeType scheme = new schemeType()
            {
                complianceYear = complianceYear,
                producerList   = new[]
                {
                    producer
                }
            };
            var result = Rule().Evaluate(scheme, producer, A.Dummy <Guid>());

            Assert.True(result.IsValid);
        }
예제 #2
0
        public static ObligationType ToDomainObligationType(this obligationTypeType obligationType)
        {
            switch (obligationType)
            {
            case obligationTypeType.B2B:
                return(ObligationType.B2B);

            case obligationTypeType.B2C:
                return(ObligationType.B2C);

            default:
                return(ObligationType.Both);
            }
        }
            ProducerAlreadyRegisteredForSameComplianceYearAndObligationType_ValidationFails_AndMessageIncludesPrnAndObligationType_AndErrorLevelIsError
            (obligationTypeType existingObligationType, obligationTypeType xmlObligationType)
        {
            var schemeId = Guid.NewGuid();

            A.CallTo(() => producerQuerySet.GetProducerForOtherSchemeAndObligationType(A<string>._, A<string>._, schemeId, A<ObligationType>._))
                .Returns(FakeProducer.Create(existingObligationType.ToDomainObligationType(), "ABC12345"));

            const string complianceYear = "2016";
            const string registrationNumber = "ABC12345";

            var producer = new producerType()
            {
                tradingName = "Test Trader",
                obligationType = xmlObligationType,
                registrationNo = registrationNumber,
                status = statusType.A,
                producerBusiness = new producerBusinessType
                {
                    Item = new partnershipType
                    {
                        partnershipName = "New Producer Name"
                    }
                }
            };

            schemeType scheme = new schemeType()
            {
                complianceYear = complianceYear,
                producerList = new[]
                    {
                       producer
                    }
            };
            var result = Rule().Evaluate(scheme, producer, schemeId);

            Assert.False(result.IsValid);
            Assert.Contains(registrationNumber, result.Message);
            Assert.Contains(existingObligationType.ToDomainObligationType().ToString(), result.Message);
            Assert.Equal(Core.Shared.ErrorLevel.Error, result.ErrorLevel);
        }
        ProducerAlreadyRegisteredForSameComplianceYearAndObligationType_ValidationFails_AndMessageIncludesPrnAndObligationType_AndErrorLevelIsError
            (obligationTypeType existingObligationType, obligationTypeType xmlObligationType)
        {
            var schemeId = Guid.NewGuid();

            A.CallTo(() => producerQuerySet.GetProducerForOtherSchemeAndObligationType(A <string> ._, A <string> ._, schemeId, A <ObligationType> ._))
            .Returns(FakeProducer.Create(existingObligationType.ToDomainObligationType(), "ABC12345"));

            const string complianceYear     = "2016";
            const string registrationNumber = "ABC12345";

            var producer = new producerType()
            {
                tradingName      = "Test Trader",
                obligationType   = xmlObligationType,
                registrationNo   = registrationNumber,
                status           = statusType.A,
                producerBusiness = new producerBusinessType
                {
                    Item = new partnershipType
                    {
                        partnershipName = "New Producer Name"
                    }
                }
            };

            schemeType scheme = new schemeType()
            {
                complianceYear = complianceYear,
                producerList   = new[]
                {
                    producer
                }
            };
            var result = Rule().Evaluate(scheme, producer, schemeId);

            Assert.False(result.IsValid);
            Assert.Contains(registrationNumber, result.Message);
            Assert.Contains(existingObligationType.ToDomainObligationType().ToString(), result.Message);
            Assert.Equal(Core.Shared.ErrorLevel.Error, result.ErrorLevel);
        }
        public void ProducerRegisteredForSameComplianceYearAndObligationTypeButPartOfSameScheme_ValidationSucceeds()
        {
            const string             complianceYear     = "2016";
            const string             registrationNumber = "ABC12345";
            var                      organisationId     = Guid.NewGuid();
            const obligationTypeType obligationType     = obligationTypeType.B2B;

            A.CallTo(() => producerQuerySet.GetProducerForOtherSchemeAndObligationType(A <string> ._, A <string> ._, A <Guid> ._, A <ObligationType> ._))
            .Returns(FakeProducer.Create(obligationType.ToDomainObligationType(), "ABC12345", organisationId));

            producerType producer = new producerType()
            {
                tradingName      = "Test Trader",
                obligationType   = obligationType,
                registrationNo   = registrationNumber,
                status           = statusType.I,
                producerBusiness = new producerBusinessType
                {
                    Item = new partnershipType
                    {
                        partnershipName = "New Producer Name"
                    }
                }
            };

            schemeType scheme = new schemeType()
            {
                complianceYear = complianceYear,
                approvalNo     = "Test approval number 1",
                producerList   = new[]
                {
                    producer
                }
            };
            var result = Rule().Evaluate(scheme, producer, A.Dummy <Guid>());

            Assert.True(result.IsValid);
        }
        public void ProducerAlreadyRegisteredForSameComplianceYearButObligationTypeDiffers_ValidationSucceeds(
            obligationTypeType existingObligationType, obligationTypeType xmlObligationType)
        {
            A.CallTo(() => producerQuerySet.GetProducerForOtherSchemeAndObligationType(A <string> ._, A <string> ._, A <Guid> ._, A <ObligationType> ._))
            .Returns(FakeProducer.Create(existingObligationType.ToDomainObligationType(), "ABC12345"));

            const string complianceYear     = "2016";
            const string registrationNumber = "ABC12345";

            producerType producer = new producerType()
            {
                tradingName      = "Test Trader",
                obligationType   = xmlObligationType,
                registrationNo   = registrationNumber,
                status           = statusType.I,
                producerBusiness = new producerBusinessType
                {
                    Item = new partnershipType
                    {
                        partnershipName = "New Producer Name"
                    }
                }
            };

            schemeType scheme = new schemeType()
            {
                complianceYear = complianceYear,
                producerList   = new[]
                {
                    producer
                }
            };
            var result = Rule().Evaluate(scheme, producer, A.Dummy <Guid>());

            Assert.True(result.IsValid);
        }
예제 #7
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 void ProducerAlreadyRegisteredForSameComplianceYearButObligationTypeDiffers_ValidationSucceeds(
            obligationTypeType existingObligationType, obligationTypeType xmlObligationType)
        {
            A.CallTo(() => producerQuerySet.GetProducerForOtherSchemeAndObligationType(A<string>._, A<string>._, A<Guid>._, A<ObligationType>._))
               .Returns(FakeProducer.Create(existingObligationType.ToDomainObligationType(), "ABC12345"));

            const string complianceYear = "2016";
            const string registrationNumber = "ABC12345";

            producerType producer = new producerType()
            {
                tradingName = "Test Trader",
                obligationType = xmlObligationType,
                registrationNo = registrationNumber,
                status = statusType.I,
                producerBusiness = new producerBusinessType
                {
                    Item = new partnershipType
                    {
                        partnershipName = "New Producer Name"
                    }
                }
            };

            schemeType scheme = new schemeType()
            {
                complianceYear = complianceYear,
                producerList = new[]
                    {
                       producer
                    }
            };
            var result = Rule().Evaluate(scheme, producer, A.Dummy<Guid>());

            Assert.True(result.IsValid);
        }