public void GetErrorMessage_Should_ContainEachFailure_When_SomeFailuresArePassed()
        {
            var failure1 = new ValidationFailure("test1", "failure on something");
            var failure2 = new ValidationFailure("test2", "failure on something else");
            var input    = new List <ValidationFailure> {
                failure1, failure2
            };

            var result = _sut.GetErrorMessage(input);

            result.Should().Contain($"{failure1.PropertyName}- {failure1.ErrorMessage}");
            result.Should().Contain($"{failure2.PropertyName}- {failure2.ErrorMessage}");
        }
        public async Task SendEmail(Email email)
        {
            var result = await _validator.ValidateAsync(email);

            if (!result.IsValid)
            {
                var validationMessage = _validationMessageFormatter.GetErrorMessage(result.Errors);
                throw new InvalidInputException(validationMessage);
            }

            try
            {
                await _smtpSender.Send(email);

                email.Success = true;
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error when sending email");
                email.Success = false;
            }

            await _emailsRepository.Create(email);
        }