public async Task Handle_ShouldSubmitMessageToFAAMessageQueueDependingOnStatus(ApplicationReviewStatus status, bool shouldPublishFaaServiceBusMessage) { FaaApplicationStatusSummary actualFaaApplicationStatusSummary = null; var faaServiceMock = new Mock <IFaaService>(); faaServiceMock.Setup(f => f.PublishApplicationStatusSummaryAsync(It.IsAny <FaaApplicationStatusSummary>())) .Callback <FaaApplicationStatusSummary>(f => actualFaaApplicationStatusSummary = f) .Returns(Task.CompletedTask); var sut = new UpdateFaaOnApplicationReviewed(faaServiceMock.Object, new Mock <ILogger <UpdateFaaOnApplicationReviewed> >().Object); var @event = new ApplicationReviewedEvent { CandidateFeedback = "candidate feedback", CandidateId = Guid.NewGuid(), Status = status, VacancyReference = 1234567890 }; await sut.Handle(@event, new CancellationToken()); faaServiceMock.Verify(f => f.PublishApplicationStatusSummaryAsync(It.IsAny <FaaApplicationStatusSummary>()), Times.Exactly(shouldPublishFaaServiceBusMessage ? 1 : 0)); if (actualFaaApplicationStatusSummary != null) { actualFaaApplicationStatusSummary.CandidateId.Should().Be(@event.CandidateId); actualFaaApplicationStatusSummary.ApplicationStatus.Should().Be(status == ApplicationReviewStatus.Successful ? FaaApplicationStatus.Successful : FaaApplicationStatus.Unsuccessful); actualFaaApplicationStatusSummary.IsRecruitVacancy.Should().Be(true); actualFaaApplicationStatusSummary.UnsuccessfulReason.Should().Be(@event.CandidateFeedback); actualFaaApplicationStatusSummary.VacancyReference.Should().Be((int)@event.VacancyReference); } }
public Task Handle(ApplicationReviewedEvent notification, CancellationToken cancellationToken) { return(Handle(notification)); }