public void TestMessageConstruction() { var sender = new SendGridSender(); var messageJob = this.MockMessageJob(); var subscribers = this.MockSubscribers(); var message = sender.ConstructMessage(messageJob, subscribers); var expected = subscribers.Select(s => s.Email).ToList(); var actual = message.Personalizations.SelectMany(x => x.Tos).Select(x => x.Email).ToList(); CollectionAssert.AreEquivalent(expected, actual); Assert.AreEqual(messageJob.MessageTemplate.BodyHtml, message.HtmlContent); Assert.AreEqual(messageJob.MessageTemplate.PlainTextVersion, message.PlainTextContent); this.AssertHeader(message); }
public void TestSubscribersResult() { // Arrange var messageJob = this.MockMessageJob(); var subscribers = this.MockNotifiableSubscribers(); var sender = new SendGridSender(); // Act var message = sender.ConstructMessage(messageJob, subscribers); var result = sender.SendMessage(messageJob, subscribers); // Assert foreach (var subscriber in subscribers) { Assert.IsTrue(subscriber.IsNotified); Assert.IsTrue(subscriber.Result == SendResultType.Success || subscriber.Result == SendResultType.FailedRecipient); } }