public void When_ValidCreateNotificationRequestEvent_Then_HaveValidData()
        {
            var createNotificationEvent   = CreateNotificationEventData.GetValidEvent();
            var createNotificationRequest = CreateNotificationRequest.Make(createNotificationEvent);

            Assert.Equal(createNotificationEvent.NotificationType, createNotificationRequest.NotificationType);
            Assert.Equal(createNotificationEvent.TemplateType, createNotificationRequest.TemplateType);
            Assert.Equal(createNotificationEvent.TemplateVersion, createNotificationRequest.TemplateVersion);
            Assert.Equal(createNotificationEvent.TemplateMapper, createNotificationRequest.TemplateMapper);
            Assert.Equal(createNotificationEvent.Receiver, createNotificationRequest.Receiver);
        }
示例#2
0
        public override async Task Handle(CreateNotificationEvent message, EventHeader header)
        {
            try
            {
                var request = CreateNotificationRequest.Make(message);

                if (request.ValidationResult.IsInvalid())
                {
                    var errors = request.ValidationResult.GetErrors();
                    _logger.LogWarning("[NotificationApp][ICreateNotificationEvent]\nInvalid request\n{@request}\n{@errors}", request, errors);
                    return;
                }

                _logger.LogInformation("[NotificationApp][ICreateNotificationEvent] Execute UseCase\n{@request}", request);

                await _createNotificationUseCase.ExecuteAsync(CreateNotificationRequest.Make(message));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
                throw;
            }
        }