Esempio n. 1
0
        public async Task PopulateAsync(CancellationToken cancellationToken)
        {
            FileDataCache fileDataCache = (FileDataCache)_fileDataCache;

            fileDataCache.UKPRN      = _fileDataRetrievalService.RetrieveUKPRN();
            fileDataCache.DPOutcomes = _fileDataRetrievalService.RetrieveDPOutcomes();
        }
        public async Task Populate()
        {
            var filePreparationDate = new DateTime(2018, 1, 5);
            var ukprn = 1;
            var learnerDestinationAndProgressions = new List <TestLearnerDestinationAndProgression>
            {
                new TestLearnerDestinationAndProgression
                {
                    LearnRefNumber = "Learner1",
                    ULN            = 9999999999,
                    DPOutcomes     = new List <TestDPOutcome>
                    {
                        new TestDPOutcome
                        {
                            OutCode      = 1,
                            OutType      = "Type",
                            OutCollDate  = new DateTime(2018, 8, 1),
                            OutStartDate = new DateTime(2018, 8, 1)
                        }
                    }
                }
            };

            var message = new TestMessage()
            {
                HeaderEntity = new TestHeader()
                {
                    CollectionDetailsEntity = new TestCollectionDetails()
                    {
                        FilePreparationDate = filePreparationDate
                    }
                },
                LearningProviderEntity = new TestLearningProvider()
                {
                    UKPRN = ukprn,
                },
                LearnerDestinationAndProgressions = learnerDestinationAndProgressions
            };

            var messageCacheMock = new Mock <ICache <IMessage> >();

            messageCacheMock.SetupGet(mc => mc.Item).Returns(message);

            var fileDataCache = new FileDataCache();

            var fileDataCachePopulationService = new FileDataCachePopulationService(fileDataCache, messageCacheMock.Object);

            await fileDataCachePopulationService.PopulateAsync(CancellationToken.None);

            fileDataCache.FilePreparationDate.Should().Be(filePreparationDate);
            fileDataCache.UKPRN.Should().Be(ukprn);
            fileDataCache.LearnerDestinationAndProgressions.Should().BeEquivalentTo(learnerDestinationAndProgressions);
        }
        public void Populate()
        {
            var filePreparationDate = new DateTime(2018, 1, 5);
            var ukprn = 1;
            var learnerDestinationAndProgressions = new List <TestLearnerDestinationAndProgression>
            {
                new TestLearnerDestinationAndProgression
                {
                    LearnRefNumber = "Learner1",
                    ULN            = 9999999999,
                    DPOutcomes     = new List <TestDPOutcome>
                    {
                        new TestDPOutcome
                        {
                            OutCode      = 1,
                            OutType      = "Type",
                            OutCollDate  = new DateTime(2018, 8, 1),
                            OutStartDate = new DateTime(2018, 8, 1),
                        },
                    },
                },
            };

            var message = new TestMessage()
            {
                HeaderEntity = new TestHeader()
                {
                    CollectionDetailsEntity = new TestCollectionDetails()
                    {
                        FilePreparationDate = filePreparationDate,
                    },
                },
                LearningProviderEntity = new TestLearningProvider()
                {
                    UKPRN = ukprn,
                },
                LearnerDestinationAndProgressions = learnerDestinationAndProgressions,
            };

            var fileDataCache = new FileDataCache();

            var validationContextMock = new Mock <IValidationContext>();

            var fileDataCachePopulationService = new FileDataCachePopulationService(fileDataCache);

            fileDataCachePopulationService.Populate(validationContextMock.Object, message);

            fileDataCache.FilePreparationDate.Should().Be(filePreparationDate);
            fileDataCache.UKPRN.Should().Be(ukprn);
        }
        public async Task Populate()
        {
            var ukprn      = 1234;
            var dpOutcomes = new Dictionary <string, IEnumerable <DPOutcome> >();

            var fileDataRetrievalServiceMock = new Mock <IFileDataRetrievalService>();

            fileDataRetrievalServiceMock.Setup(rds => rds.RetrieveUKPRN()).Returns(ukprn);
            fileDataRetrievalServiceMock.Setup(rds => rds.RetrieveDPOutcomes()).Returns(dpOutcomes);

            var fileDataCache = new FileDataCache();

            await NewService(fileDataCache, fileDataRetrievalServiceMock.Object).PopulateAsync(CancellationToken.None);

            fileDataCache.UKPRN.Should().Be(ukprn);
            fileDataCache.DPOutcomes.Should().BeSameAs(dpOutcomes);
        }