Ejemplo n.º 1
0
            public TransferRequestApprovedEventHandlerForEmailNotificationsTestsFixture()
            {
                _autoFixture = new Fixture();

                _messageHandlerContext = new Mock <IMessageHandlerContext>();
                _pipelineContext       = _messageHandlerContext.As <IPipelineContext>();

                _cohortReference          = _autoFixture.Create <string>();
                _employerEncodedAccountId = _autoFixture.Create <string>();
                _encodingService          = new Mock <IEncodingService>();
                _encodingService.Setup(x => x.Encode(It.Is <long>(id => id == _cohortSummary.CohortId),
                                                     EncodingType.CohortReference)).Returns(_cohortReference);
                _encodingService.Setup(x => x.Encode(It.Is <long>(id => id == _cohortSummary.AccountId),
                                                     EncodingType.AccountId)).Returns(_employerEncodedAccountId);

                _mediator = new Mock <IMediator>();
                _mediator.Setup(x => x.Send(It.IsAny <AddTransferRequestCommand>(), It.IsAny <CancellationToken>()))
                .ReturnsAsync(new Unit());

                _cohortSummary = _autoFixture.Create <GetCohortSummaryQueryResult>();
                _mediator.Setup(x => x.Send(It.IsAny <GetCohortSummaryQuery>(),
                                            It.IsAny <CancellationToken>()))
                .ReturnsAsync(_cohortSummary);

                _handler = new TransferRequestApprovedEventHandlerForEmailNotifications(_mediator.Object, _encodingService.Object);

                _event = new TransferRequestApprovedEvent(_autoFixture.Create <long>(),
                                                          _autoFixture.Create <long>(),
                                                          _autoFixture.Create <DateTime>(),
                                                          _autoFixture.Create <UserInfo>()
                                                          );
            }
Ejemplo n.º 2
0
        public TransferRequestApprovedEventHandlerTestsFixture()
        {
            _fixture          = new Fixture();
            UnitOfWorkContext = new UnitOfWorkContext();
            Db = new ProviderCommitmentsDbContext(new DbContextOptionsBuilder <ProviderCommitmentsDbContext>()
                                                  .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                                  .ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning))
                                                  .Options);

            TransferSenderUserInfo       = _fixture.Create <UserInfo>();
            TransferRequestApprovedEvent = new TransferRequestApprovedEvent(_fixture.Create <long>(), _fixture.Create <long>(), _fixture.Create <DateTime>(), TransferSenderUserInfo);

            Logger = new FakeLogger <TransferRequestApprovedEvent>();
            LegacyTopicMessagePublisher = new Mock <ILegacyTopicMessagePublisher>();
            Handler = new TransferRequestApprovedEventHandler(new Lazy <ProviderCommitmentsDbContext>(() => Db), LegacyTopicMessagePublisher.Object, Logger);

            Cohort = new Cohort(
                _fixture.Create <long>(),
                _fixture.Create <long>(),
                _fixture.Create <long>(),
                null,
                Party.Employer,
                "",
                new UserInfo())
            {
                Id = TransferRequestApprovedEvent.CohortId, EmployerAccountId = 100, TransferSenderId = 99
            };

            ExistingApprenticeshipDetails = new DraftApprenticeship(_fixture.Build <DraftApprenticeshipDetails>().Create(), Party.Provider);
            Cohort.Apprenticeships.Add(ExistingApprenticeshipDetails);
            Cohort.WithParty = Party.TransferSender;
            Cohort.TransferApprovalStatus = TransferApprovalStatus.Pending;
        }