public void SendMessage_Attachment(string cc, string bcc, int noOfAttachments, string expected) { // Setup var provider = new MailToEmailProviderDummy(); var email = provider.CreateMessage(); email.To.Add("*****@*****.**"); if (cc != null) { email.Cc.AddRange(cc.Split(';')); } if (bcc != null) { email.Bcc.AddRange(bcc.Split(';')); } email.Subject = "Testing"; email.Body = "Hi there"; var tempFiles = new List <TempFile>(); try { var bldr = new StringBuilder(); for (var i = 0; i < noOfAttachments; i++) { var tempFile = new TempFile($"SendMessage_Attachment{i}"); tempFiles.Add(tempFile); email.AttachmentFilePath.Add(tempFile.Path); if (bldr.Length > 0) { bldr.Append(","); } bldr.Append($"\"{tempFile.Path}\""); } // Exercise provider.SendMessage(email); // Verify var fullExpected = expected.Replace(" $ATTACH", $"&attachment={bldr}"); Assert.That(provider.GetCommandLine(), Is.EqualTo(fullExpected)); } catch { foreach (var tempFile in tempFiles) { tempFile.Dispose(); } throw; } }
public string SendMessage_ToOnly(string to) { // Setup var provider = new MailToEmailProviderDummy(); var email = provider.CreateMessage(); email.To.AddRange(to.Split(';')); email.Subject = "Testing"; email.Body = "Hi there"; // Exercise provider.SendMessage(email); // Verify return(provider.GetCommandLine()); }
public string SendMessage_CcAndBcc(string cc, string bcc) { // Setup var provider = new MailToEmailProviderDummy(); var email = provider.CreateMessage(); email.To.Add("*****@*****.**"); if (cc != null) { email.Cc.AddRange(cc.Split(';')); } if (bcc != null) { email.Bcc.AddRange(bcc.Split(';')); } email.Subject = "Testing"; email.Body = "Hi there"; // Exercise provider.SendMessage(email); // Verify return(provider.GetCommandLine()); }