Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zs40x/5b8e5e88524d8f2812db to your computer and use it in GitHub Desktop.
Save zs40x/5b8e5e88524d8f2812db to your computer and use it in GitHub Desktop.
[TestMethod]
public void isNonPremiumUserMailSentAndValid()
{
var user = new User("A", "A@B.com", false);
var expectedSubject = "Notification";
var expectedMessage = "Dear A this is a Notification!";
var sendMail = Mock.Create<SendMail>();
new NotificationService(sendMail).sendNotificationForUser(user);
Mock.Assert(
() => sendMail.sendMail(user.EMailAddress, expectedSubject, expectedMessage),
Occurs.Once(),
"sendMail() wasn't called as expected!"
);
}
[TestMethod]
public void isPremiumUserMailSendAndValid()
{
var user = new User("Premium", "Premium@User.com", true);
var expectedSubject = "Notification";
var expectedMessage = "Dear Premium this is a Notification! -> Additional Information for Premium Users!";
var sendMail = Mock.Create<SendMail>();
new NotificationService(sendMail).sendNotificationForUser(user);
Mock.Assert(
() => sendMail.sendMail(user.EMailAddress, expectedSubject, expectedMessage),
Occurs.Once(),
"sendMail() wasn't called as expected!"
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment