public void Send_Should_Throw_EmailException_When_Model_Is_Null() { // Arrange EmailTemplateStub emailTemplate = new EmailTemplateStub(_applicationSettings, _siteSettings, _emailClientMock); UserViewModel userModel = null; // Act + Assert emailTemplate.Send(userModel); }
public void Send_Should_Throw_EmailException_When_Model_Email_And_NewEmail_Is_Empty() { // Arrange EmailTemplateStub emailTemplate = new EmailTemplateStub(_applicationSettings, _repository, _emailClientMock); UserViewModel userModel = new UserViewModel(); userModel.ExistingEmail = null; userModel.NewEmail = ""; // Act + Assert emailTemplate.Send(userModel); }
public void Send_Should_Throw_EmailException_When_PlainTextView_Is_Empty() { // Arrange EmailTemplateStub emailTemplate = new EmailTemplateStub(_applicationSettings, _siteSettings, _emailClientMock); emailTemplate.PlainTextView = ""; UserViewModel userModel = new UserViewModel(); userModel.ExistingEmail = "someone@localhost"; userModel.NewEmail = "someone@localhost"; // Act + Assert emailTemplate.Send(userModel); }
public void Send_Should_Use_EmailClient_To_Send() { // Arrange EmailTemplateStub emailTemplate = new EmailTemplateStub(_applicationSettings, _siteSettings, _emailClientMock); UserViewModel userModel = new UserViewModel(); userModel.ExistingEmail = "someone@localhost"; userModel.NewEmail = "someone@localhost"; // Act emailTemplate.Send(userModel); // Assert Assert.That(_emailClientMock.Sent, Is.True); }
public void Send_Should_Change_PickupDirectory_To_AppDomainRoot_When_Starting_With_VirtualPath_And_DeliveryType_Is_PickupLocation() { // Arrange EmailTemplateStub emailTemplate = new EmailTemplateStub(_applicationSettings, _siteSettings, _emailClientMock); _emailClientMock.PickupDirectoryLocation = "~/App_Data/EmailDrop"; _emailClientMock.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; UserViewModel userModel = new UserViewModel(); userModel.ExistingEmail = "someone@localhost"; userModel.NewEmail = "someone@localhost"; // Act emailTemplate.Send(userModel); // Assert Assert.That(_emailClientMock.PickupDirectoryLocation, Is.StringStarting(AppDomain.CurrentDomain.BaseDirectory)); }
public void Send_Should_Set_Two_Alternative_Views_With_PlainText_And_Html() { // Arrange EmailTemplateStub emailTemplate = new EmailTemplateStub(_applicationSettings, _siteSettings, _emailClientMock); UserViewModel userModel = new UserViewModel(); userModel.ExistingEmail = "someone@localhost"; userModel.NewEmail = "someone@localhost"; // Act emailTemplate.Send(userModel); // Assert MailMessage message = _emailClientMock.Message; Assert.That(message.AlternateViews.Count, Is.EqualTo(2)); AlternateView plainView = message.AlternateViews.FirstOrDefault(x => x.ContentType.MediaType == "text/plain"); AlternateView htmlView = message.AlternateViews.FirstOrDefault(x => x.ContentType.MediaType == "text/html"); Assert.That(plainView, Is.Not.Null); Assert.That(htmlView, Is.Not.Null); }