public void CreateReference_Sets_NoteReference()
        {
            //arrange
            const string reference = "ABCDE12345";
            var mockReferenceGenerator = new Mock<IReferenceGenerator>();
            var email = new Email();

            mockReferenceGenerator.Setup(x => x.CreateReference(It.IsAny<int>())).Returns(reference);

            //act
            email.CreateReference(mockReferenceGenerator.Object);

            //assert
            email.EmailReference.Should().NotBeNullOrWhiteSpace();
            email.EmailReference.Should().Be(reference);

            mockReferenceGenerator.Verify(x => x.CreateReference(It.IsAny<int>()), Times.Once);
        }
        public string Send(Email email)
        {
            var config = _mailboxConfiguration.Mailboxes.FirstOrDefault(x => x.Outbound);

            if (config.IsNull())
                return string.Empty;

            _emailRepository.CreateEmail(email.CreateReference(_referenceGenerator).SetDirection(Direction.Outbound).SetAccountName(config.AccountName));

            if (!_emailServiceSettings.SendEnabled)
                return email.EmailReference;

            var result = _emailProvider.SendEmail(config, email);

            _emailRepository.UpdateStatus(email.EmailReference, result ? Status.Success : Status.Error);

            return result ? email.EmailReference : string.Empty;
        }