public async Task Handle_JustCalled_PublishChallengeUpdatedEvent() { // Arrange var quizId = "42"; var mathChallenge = new MathChallenge() { Question = "2+2=4?", IsCompleted = false, IsCorrect = true }; _mathChallengeServiceMock .Setup(m => m.CreateChallenge()) .Returns(mathChallenge); var @event = new ChallengeStarting { QuizId = quizId, StartDate = DateTimeOffset.UtcNow }; // Act await _handler.Handle(@event); // Assert _eventBusMock.Verify(x => x.Publish( It.Is <ChallengeUpdated>(e => e.QuizId == quizId && e.Question == mathChallenge.Question))); _eventBusMock.VerifyNoOtherCalls(); }
public async Task Handle_JustCalled_CreateChallengeAndSetToQuiz() { // Arrange var quizId = "42"; var mathChallenge = new MathChallenge() { Question = "2+2=4?", IsCompleted = false, IsCorrect = true }; _mathChallengeServiceMock .Setup(m => m.CreateChallenge()) .Returns(mathChallenge); var @event = new ChallengeStarting { QuizId = quizId, StartDate = DateTimeOffset.UtcNow }; // Act await _handler.Handle(@event); // Assert _mathChallengeServiceMock.Verify(x => x.CreateChallenge()); _mathChallengeServiceMock.VerifyNoOtherCalls(); _quizServiceMock.Verify(x => x.SetChallengeToQuiz(quizId, mathChallenge.Question, mathChallenge.IsCorrect)); _quizServiceMock.VerifyNoOtherCalls(); }