public async Task Stores_New_Apprenticeships()
        {
            var service = mocker.Create <ApprenticeshipService>();
            await service.NewApprenticeship(apprenticeship);

            mocker.Mock <IApprenticeshipRepository>()
            .Verify(x => x.Add(It.Is <ApprenticeshipModel>(model =>
                                                           model.Id == apprenticeship.Id &&
                                                           model.AccountId == apprenticeship.AccountId &&
                                                           model.Uln == apprenticeship.Uln &&
                                                           model.Ukprn == apprenticeship.Ukprn)), Times.Once);
        }
        public async Task Publishes_Period_End_Started_Event_From_Period_End_Start_Task()
        {
            var jobContextMessage = new JobContextMessage
            {
                JobId  = 1,
                Topics = new List <ITopicItem>
                {
                    new TopicItem
                    {
                        SubscriptionName = "PeriodEnd",
                        Tasks            = new List <ITaskItem>
                        {
                            new TaskItem
                            {
                                SupportsParallelExecution = false,
                                Tasks = new List <string> {
                                    "PeriodEndStart"
                                }
                            }
                        }
                    }
                },
                KeyValuePairs = new Dictionary <string, object> {
                    { JobContextMessageConstants.KeyValuePairs.ReturnPeriod, 10 },
                    { JobContextMessageConstants.KeyValuePairs.CollectionYear, 1819 }
                }
            };

            var handler = mocker.Create <PeriodEndJobContextMessageHandler>();
            await handler.HandleAsync(jobContextMessage, CancellationToken.None);

            mocker.Mock <IEndpointInstance>()
            .Verify(x => x.Publish(It.Is <PeriodEndStartedEvent>(startedEvent => startedEvent.JobId == 1 &&
                                                                 startedEvent.CollectionPeriod.Period == 10 &&
                                                                 startedEvent.CollectionPeriod.AcademicYear == 1819),
                                   It.IsAny <PublishOptions>()), Times.Once);
        }
Esempio n. 3
0
        public async Task Publishes_Period_End_Started_Event_From_Period_End_Start_Task()
        {
            var jobContextMessage = CreatePeriodEndJobContextMessage(PeriodEndTaskType.PeriodEndStart);

            var handler = mocker.Create <PeriodEndJobContextMessageHandler>();
            await handler.HandleAsync(jobContextMessage, CancellationToken.None);

            mocker.Mock <IEndpointInstance>()
            .Verify(x => x.Publish(It.Is <PeriodEndStartedEvent>(startedEvent => startedEvent.JobId == 1 &&
                                                                 startedEvent.CollectionPeriod.Period == 10 &&
                                                                 startedEvent.CollectionPeriod.AcademicYear == 1819),
                                   It.IsAny <PublishOptions>()), Times.Once);
        }
        public async Task Processes_ApprenticeshipCreated()
        {
            var approvalsEvent = new ApprenticeshipCreatedEvent
            {
                AccountId = 12345,
                StartDate = DateTime.Today,
                AccountLegalEntityPublicHashedId = "1234567890",
                AgreedOn         = DateTime.Today.AddDays(-1),
                ApprenticeshipId = 12,
                CreatedOn        = DateTime.Today.AddDays(-2),
                EndDate          = DateTime.Today.AddYears(1),
                LegalEntityName  = "Test Employer",
                ProviderId       = 1234,
                TrainingCode     = "52",
                TrainingType     = ProgrammeType.Standard,
                TransferSenderId = 123456,
                Uln           = "123456",
                PriceEpisodes = new PriceEpisode[] { new PriceEpisode {
                                                         FromDate = DateTime.Today, Cost = 1000M
                                                     } }
            };

            mocker.Mock <IApprenticeshipService>()
            .Setup(svc => svc.NewApprenticeship(It.IsAny <ApprenticeshipModel>()))
            .ReturnsAsync(() => new List <ApprenticeshipDuplicateModel>());

            var apprenticeshipProcessor = mocker.Create <ApprenticeshipProcessor>();
            await apprenticeshipProcessor.Process(approvalsEvent);

            mocker.Mock <IApprenticeshipService>()
            .Verify(svc => svc.NewApprenticeship(It.Is <ApprenticeshipModel>(model =>
                                                                             model.AccountId == approvalsEvent.AccountId &&
                                                                             model.Id == approvalsEvent.ApprenticeshipId &&
                                                                             model.Ukprn == approvalsEvent.ProviderId &&
                                                                             model.Uln.ToString() == approvalsEvent.Uln)
                                                 ), Times.Once);
        }