Beispiel #1
0
        public ProducerSubmission GetLatestProducerForComplianceYearAndScheme(string registrationNo, string schemeComplianceYear, Guid organisationId)
        {
            int complianceYear = int.Parse(schemeComplianceYear);

            if (!currentProducersByRegistrationNumber.Run().ContainsKey(registrationNo))
            {
                return(null);
            }

            return(currentProducersByRegistrationNumber.Run()[registrationNo]
                   .Where(p => p.RegisteredProducer.ComplianceYear == complianceYear)
                   .Where(p => p.RegisteredProducer.Scheme.OrganisationId == organisationId)
                   .SingleOrDefault());
        }
        public void GetLatestProducerForComplianceYearAndScheme_AllParametersMatch_ReturnsProducer()
        {
            var schemeOrganisationId = Guid.NewGuid();
            var registrationNumber   = "ABC12345";
            var complianceYear       = 2016;

            var producer = FakeProducer.Create(ObligationType.Both, registrationNumber, schemeOrganisationId, complianceYear);

            A.CallTo(() => currentProducersByRegistrationNumber.Run())
            .Returns(new Dictionary <string, List <ProducerSubmission> >
            {
                { registrationNumber, new List <ProducerSubmission> {
                      producer
                  } }
            });

            var result = ProducerQuerySet().GetLatestProducerForComplianceYearAndScheme(registrationNumber, complianceYear.ToString(), schemeOrganisationId);

            Assert.Equal(producer, result);
        }