I have written a wrappper service around sendgrid and all of the pieces work except for the actual sending of the email.
service:
public class SendGridService : ISendGridService
{
public async Task Send(Email email)
{
var preparedEmail = PrepareEmail(email);
var apiKey = ConfigurationManager.AppSettings["sendGridApiKey"];
var transportWeb = new Web(apiKey);
await transportWeb.DeliverAsync(preparedEmail);
}
//other methods that prepare the email
}
Test class I am using to see if the email is sent:
[Test]
public void Send_ShouldSendEmailToOneAddress()
{
//arrange
//uses NBuilder to mock the object
var email = Builder<Email>.CreateNew()
.With(x => x.Recipient = "me@me.com")
.With(x => x.Sender = "me@me.com")
.With(x => x.SenderName = "me")
.With(x => x.FilePathAttachement = null)
.With(x => x.Html = null)
.Build();
//act
var temp = _sut.Send(email);
//assert
}
I realize the test isnt acually testing anything but I was hoping to see the email in my inbox and then write true false tests around the code.
I never recieve an email is the problem. What am I missing to make the email actually send.