Example #1
0
        public void PublishIndexUpdateForApprenticeship()
        {
            //Arrange
            var apprenticeshipVacancy = new Vacancy
            {
                Status      = VacancyStatus.Live,
                VacancyType = VacancyType.Apprenticeship
            };

            _mockApprenticeshipVacancyWriteRepository.Setup(r => r.Create(apprenticeshipVacancy)).Returns(apprenticeshipVacancy);

            //Act
            _publishVacancySummaryUpdateStrategy.PublishVacancySummaryUpdate(apprenticeshipVacancy);

            //Assert
            _mockServiceBus.Verify(sb => sb.PublishMessage((ApprenticeshipSummaryUpdate)null), Times.Never);
            _mockServiceBus.Verify(sb => sb.PublishMessage(It.IsAny <ApprenticeshipSummaryUpdate>()), Times.Once);
        }
Example #2
0
        public Vacancy UpsertVacancy(Vacancy vacancy, Func <Vacancy, Vacancy> operation)
        {
            Condition.Requires(vacancy);

            _authoriseCurrentUserStrategy.AuthoriseCurrentUser(vacancy);

            if (_currentUserService.IsInRole(Roles.Faa))
            {
                var username     = _currentUserService.CurrentUserName;
                var lastEditedBy = _providerUserReadRepository.GetByUsername(username);
                if (lastEditedBy != null)
                {
                    vacancy.LastEditedById = lastEditedBy.ProviderUserId;
                }
            }

            vacancy = operation(vacancy);

            _publishVacancySummaryUpdateStrategy.PublishVacancySummaryUpdate(vacancy);

            return(_vacancyReadRepository.Get(vacancy.VacancyId));
        }