diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-05-06 18:01:50 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-05-06 18:01:50 +0300 |
| commit | d967b4b37644ab6aedac36539f8f6fa5cf3547f2 (patch) | |
| tree | 68433d120d479480c6f50f21d4dcf9d21a21bdfe /Software/Visual_Studio/Tango.UnitTesting/SendGrid | |
| parent | 12d7bb4a0323fa4b037a93036cc32f1e2e7cb591 (diff) | |
| download | Tango-d967b4b37644ab6aedac36539f8f6fa5cf3547f2.tar.gz Tango-d967b4b37644ab6aedac36539f8f6fa5cf3547f2.zip | |
Working on TCC..
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting/SendGrid')
| -rw-r--r-- | Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs new file mode 100644 index 000000000..785fa42bf --- /dev/null +++ b/Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs @@ -0,0 +1,39 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SendGrid; +using SendGrid.Helpers.Mail; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.UnitTesting.SendGrid +{ + [TestClass] + [TestCategory("SendGrid")] + public class SendGrid_TST + { + private const string KEY = "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"; + + [TestMethod] + public void Send_Simple_Email() + { + var client = new SendGridClient(KEY); + var from = new EmailAddress("test@example.com", "Example User"); + var subject = "Sending with SendGrid is Fun"; + var to = new EmailAddress("roy@twine-s.com", "Roy Ben Shabat"); + var plainTextContent = "and easy to do anywhere, even with C#"; + var htmlContent = "<div style='color:red;'>and easy to do anywhere, even with C#</strong>"; + var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent); + + var bytes = File.ReadAllBytes(@"D:\Downloads\Twine TWN Spec (3).pdf"); + var file = Convert.ToBase64String(bytes); + msg.AddAttachment("Twine Spec.pdf", file, "application/pdf"); + + var response = client.SendEmailAsync(msg).GetAwaiter().GetResult(); + + Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.Accepted); + } + } +} |
