예제 #1
0
        public void SendMessage_ToCcAndBccNoAttachment()
        {
            // Setup
            var provider = new MacOsXEmailProviderDummy();
            var email    = provider.CreateMessage();

            email.To.Add("*****@*****.**");
            email.Cc.Add("*****@*****.**");
            email.Bcc.Add("*****@*****.**");
            email.Subject = "My subject";
            email.Body    = "This is a test email.";

            // Execute
            provider.SendMessage(email);

            // Verify
            var startInfo = provider.StartInfo;

            Assert.That(startInfo.FileName, Is.EqualTo("osascript"));
            Assert.That(startInfo.Arguments, Is.EqualTo(
                            @"-e 'tell application ""Mail""
tell (make new outgoing message)
set subject to ""My subject""
set content to ""This is a test email.""
-- set visible to true
make new to recipient at end of to recipients with properties {address:""*****@*****.**""}
make new to recipient at end of cc recipients with properties {address:""*****@*****.**""}
make new to recipient at end of bcc recipients with properties {address:""*****@*****.**""}
end tell
end tell'
"));
        }
예제 #2
0
        public void SendMessage_SingleRecptMultipleAttachments()
        {
            // Setup
            var provider = new MacOsXEmailProviderDummy();
            var email    = provider.CreateMessage();

            email.To.Add("*****@*****.**");
            email.Subject = "My subject";
            email.Body    = "This is a test email.";
            using (var tempFile1 = new TempFile("SendMessage_SingleRecptMultipleAttachments1"))
                using (var tempFile2 = new TempFile("SendMessage_SingleRecptMultipleAttachments2"))
                {
                    email.AttachmentFilePath.Add(tempFile1.Path);
                    email.AttachmentFilePath.Add(tempFile2.Path);

                    // Execute
                    provider.SendMessage(email);

                    // Verify
                    var startInfo = provider.StartInfo;
                    Assert.That(startInfo.FileName, Is.EqualTo("osascript"));
                    Assert.That(startInfo.Arguments, Is.EqualTo(
                                    $@"-e 'tell application ""Mail""
tell (make new outgoing message)
set subject to ""My subject""
set content to ""This is a test email.""
-- set visible to true
make new to recipient at end of to recipients with properties {{address:""*****@*****.**""}}
make new attachment with properties {{file name:""{tempFile1.Path}""}} at after the last paragraph
make new attachment with properties {{file name:""{tempFile2.Path}""}} at after the last paragraph
end tell
end tell'
"));
                }
        }