public async Task Should_get_template_by_notification_type_happy() { foreach (var notificationType in Enum.GetValues(typeof(NotificationType)).OfType <NotificationType>()) { // Arrange var template = new Template(Guid.NewGuid(), notificationType, MessageType.Email, "parameters"); _mocker.Mock <IQueryHandler>().Setup(x => x.Handle <GetTemplateByNotificationTypeQuery, Template>(It.Is <GetTemplateByNotificationTypeQuery>(y => y.NotificationType == notificationType))).ReturnsAsync(template); // Act var result = await _sut.GetTemplateByNotificationTypeAsync((Contract.NotificationType) notificationType); // Assert _mocker.Mock <IQueryHandler>().Verify(x => x.Handle <GetTemplateByNotificationTypeQuery, Template>(It.Is <GetTemplateByNotificationTypeQuery>(y => y.NotificationType == notificationType)), Times.Once); result.Should().BeOfType <OkObjectResult>(); var okResult = result as OkObjectResult; okResult.Value.Should().BeOfType <NotificationTemplateResponse>(); var notificationTemplateResponse = okResult.Value as NotificationTemplateResponse; notificationTemplateResponse.Id.Should().Be(template.Id); notificationTemplateResponse.NotificationType.Should().Be((int)notificationType); notificationTemplateResponse.NotifyTemplateId.Should().Be(template.NotifyTemplateId); notificationTemplateResponse.Parameters.Should().Be(template.Parameters); } }