public async Task SetValueAsync_SendsMessage() { InvalidOperationException ex = await Assert.ThrowsAsync <InvalidOperationException>( async() => { await _valueBinder.SetValueAsync(_message, CancellationToken.None); }); Assert.Equal("A 'To' address must be specified for the message.", ex.Message); _message.AddTo("*****@*****.**"); ex = await Assert.ThrowsAsync <InvalidOperationException>( async() => { await _valueBinder.SetValueAsync(_message, CancellationToken.None); }); Assert.Equal("A 'From' address must be specified for the message.", ex.Message); }
public async Task SetValueAsync_InvalidMessage_Throws() { Web web = new Web("1234"); SendGridMessage message = new SendGridMessage { From = new System.Net.Mail.MailAddress("*****@*****.**") }; message.AddTo("*****@*****.**"); SendGridValueBinder binder = new SendGridValueBinder(web, message); // SendGrid isn't mockable, so we're just catching their exception as proof // that we called send await Assert.ThrowsAsync<Exceptions.InvalidApiRequestException>( async () => { await binder.SetValueAsync(message, CancellationToken.None); }); }
public async Task SetValueAsync_InvalidMessage_Throws() { Web web = new Web("1234"); SendGridMessage message = new SendGridMessage { From = new System.Net.Mail.MailAddress("*****@*****.**") }; message.AddTo("*****@*****.**"); SendGridValueBinder binder = new SendGridValueBinder(web, message); // SendGrid isn't mockable, so we're just catching their exception as proof // that we called send await Assert.ThrowsAsync <Exceptions.InvalidApiRequestException>( async() => { await binder.SetValueAsync(message, CancellationToken.None); }); }