public async Task ThenAProviderApproveCohortCommandIsSent()
        {
            await Target.Handle(Command);

            V2EventsPublisher.Verify(x => x.SendProviderApproveCohortCommand(Command.CommitmentId,
                                                                             It.Is <string>(m => m == Command.Message),
                                                                             It.Is <UserInfo>(u =>
                                                                                              u.UserId == Command.UserId &&
                                                                                              u.UserDisplayName == Command.LastUpdatedByName &&
                                                                                              u.UserEmail == Command.LastUpdatedByEmail)));
        }
        public async Task If_CohortIsAChangePartyRequest_Then_CohortWithChangeOfPartyRequestEventIsPublished()
        {
            Commitment.ChangeOfPartyRequestId = 100;

            await Target.Handle(Command);

            V2EventsPublisher.Verify(x => x.PublishCohortWithChangeOfPartyUpdatedEvent(Command.CommitmentId,
                                                                                       It.Is <UserInfo>(u =>
                                                                                                        u.UserId == Command.UserId &&
                                                                                                        u.UserDisplayName == Command.LastUpdatedByName &&
                                                                                                        u.UserEmail == Command.LastUpdatedByEmail)));
        }
        public void SetUp()
        {
            Validator = new ProviderApproveCohortCommandValidator();
            Command   = new ProviderApproveCohortCommand {
                Caller = new Caller(213, CallerType.Provider), CommitmentId = 123, LastUpdatedByName = "Test", LastUpdatedByEmail = "*****@*****.**", Message = "Some text"
            };
            SetUpCommonMocks();
            Commitment            = CreateCommitment(Command.CommitmentId, 11234, Command.Caller.Id);
            Commitment.EditStatus = EditStatus.ProviderOnly;
            Account = CreateAccount(Commitment.EmployerAccountId, ApprenticeshipEmployerType.Levy);
            CommitmentRepository.Setup(x => x.GetCommitmentById(Command.CommitmentId)).ReturnsAsync(Commitment);
            EmployerAccountsService.Setup(x => x.GetAccount(Commitment.EmployerAccountId)).ReturnsAsync(Account);
            SetupSuccessfulOverlapCheck();
            V2EventsPublisher.Setup(x => x.SendProviderApproveCohortCommand(It.IsAny <long>(), It.IsAny <string>(), It.IsAny <UserInfo>()))
            .Returns(Task.CompletedTask);

            Target = new ProviderApproveCohortCommandHandler(Validator,
                                                             CommitmentRepository.Object,
                                                             V2EventsPublisher.Object);
        }
        public async Task If_CohortIsNotAChangePartyRequest_Then_CohortWithChangeOfPartyRequestEventIsNotPublished()
        {
            await Target.Handle(Command);

            V2EventsPublisher.Verify(x => x.PublishCohortWithChangeOfPartyUpdatedEvent(It.IsAny <long>(), It.IsAny <UserInfo>()), Times.Never());
        }