<commit_before>﻿using System;
using System.IO;
using System.Threading.Tasks;
using Mailgun.Messages;
using Mailgun.Service;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
using Should;

namespace Mailgun.Tests.Service
{
    [TestClass]
    public class MessageServiceSpec
    {
        private const string ApiKey = "[apikeyHere]";
        private const string Domain = "sandbox9adbe277a51a430daeb12aaa652af7f1.mailgun.org";


        [TestMethod]
        public async Task TestSendBatchMessage()
        {
                    var mg = new MessageService(ApiKey);

            //build a message
            var builder = new MessageBuilder()
                .SetTestMode(true)
                .SetSubject("Plain text test")
                .SetFromAddress(new Recipient {Email = "<EMAIL>", DisplayName = "Mailgun C#"})
                .SetTextBody("This is a test");

            //add 1000 users
            for (var i = 0; i < 1000; i++)
            {
                builder.AddToRecipient(new Recipient() {Email = string.Format("<EMAIL>{0}<EMAIL>", i)},JObject.Parse("{\"\":"+i+"}"));
            }

            var content = await mg.SendMessageAsync(Domain, builder.GetMessage());
            content.ShouldNotBeNull();
        }

        [TestMethod]
        public async Task TestSendMessage()
        {
            var mg = new MessageService(ApiKey);

            //build a message
            var message = new MessageBuilder()
                .AddToRecipient(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "<NAME>"
                })
                .SetTestMode(true)
                .SetSubject("Plain text test")
                .SetFromAddress(new Recipient {Email = "<EMAIL>", DisplayName = "Mailgun C#"})
                .SetTextBody("This is a test")
                .GetMessage();

            var content = await mg.SendMessageAsync(Domain, message);
            content.ShouldNotBeNull();
        }

        [TestMethod]
        public async Task TestSendHtmlMessage()
        {
            var mg = new MessageService(ApiKey);

            //build a message
            var message = new MessageBuilder()
                .AddToRecipient(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "<NAME>"
                })
                .SetTestMode(true)
                .SetSubject("Html test")
                .SetFromAddress(new Recipient {Email = "<EMAIL>", DisplayName = "Mailgun C#"})
                .SetHtmlBody("<html><h1>Hello from the Mailgun C# library</h1></html>")
                .GetMessage();

            var content = await mg.SendMessageAsync(Domain, message);
            content.ShouldNotBeNull();
        }

        [TestMethod]
        public async Task TestSendAttachments()
        {
            var mg = new MessageService(ApiKey);

            //build a message
            var message = new MessageBuilder()
                .AddToRecipient(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "<NAME>"
                })
                .SetTestMode(true)
                .SetSubject("Attachment test")
                .SetFromAddress(new Recipient {Email = "<EMAIL>", DisplayName = "Mailgun C#"})
                .SetHtmlBody("<html><h1>I have an attachment</h1></html>")
                .AddAttachment(new FileInfo("C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg"))
                .GetMessage();

            var content = await mg.SendMessageAsync(Domain, message);
            content.ShouldNotBeNull();
        }

        [TestMethod]
        public async Task TestInlineImage()
        {
            var mg = new MessageService(ApiKey);

            //build a message
            var message = new MessageBuilder()
                .AddToRecipient(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "<NAME>"
                })
                .SetTestMode(true)
                .SetSubject("Inline image test")
                .SetFromAddress(new Recipient {Email = "<EMAIL>", DisplayName = "Mailgun C#"})
                .SetHtmlBody("<html>Inline image here: <img src=\"cid:Desert.jpg\"></html>")
                .AddInlineImage(new FileInfo("C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg"))
                .GetMessage();

            var content = await mg.SendMessageAsync(Domain, message);
            content.ShouldNotBeNull();
        }

        [TestMethod]
        public async Task TestKitchenSink()
        {
            var mg = new MessageService(ApiKey);

            //build a message
            var message = new MessageBuilder()
                .SetTestMode(true)
                .AddToRecipient(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "<NAME>"
                })
                .AddCcRecipient(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "Tester"
                })
                .AddBccRecipient(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "Tester"
                })
                .SetReplyToAddress(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "Tester Reply"
                })
                .AddCustomData("Some Data", JObject.Parse("{\"test\":\"A test json object\"}"))
                .AddCustomHeader("X-My-Custom-Header", "Custom Header")
                .AddCustomParameter("CustomParam", "A custom parameter")
                .AddTag("Kitchen sink Tag")
                .AddCampaignId("fake_campaign_id")
                .SetClickTracking(true)
                .SetDkim(true)
                .SetOpenTracking(true)
                .SetDeliveryTime(DateTime.Now + TimeSpan.FromDays(1))
                .SetSubject("Kitchen Sink")
                .SetFromAddress(new Recipient {Email = "<EMAIL>", DisplayName = "Mailgun C#"})
                .SetTextBody("This is the text body")
                .SetHtmlBody("<html>Inline image here: <img src=\"cid:Desert.jpg\"></html>")
                .AddInlineImage(new FileInfo("C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg"))
                .AddAttachment(new FileInfo("C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg"))
                .GetMessage();

            var content = await mg.SendMessageAsync(Domain, message);
            content.ShouldNotBeNull();
        }
    }
}<commit_msg>Added back id<commit_after>﻿using System;
using System.IO;
using System.Threading.Tasks;
using Mailgun.Messages;
using Mailgun.Service;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
using Should;

namespace Mailgun.Tests.Service
{
    [TestClass]
    public class MessageServiceSpec
    {
        private const string ApiKey = "[apikeyHere]";
        private const string Domain = "sandbox9adbe277a51a430daeb12aaa652af7f1.mailgun.org";


        [TestMethod]
        public async Task TestSendBatchMessage()
        {
                    var mg = new MessageService(ApiKey);

            //build a message
            var builder = new MessageBuilder()
                .SetTestMode(true)
                .SetSubject("Plain text test")
                .SetFromAddress(new Recipient {Email = "<EMAIL>", DisplayName = "Mailgun C#"})
                .SetTextBody("This is a test");

            //add 1000 users
            for (var i = 0; i < 1000; i++)
            {
                builder.AddToRecipient(new Recipient() {Email = string.Format("<EMAIL>{0}<EMAIL>", i)},JObject.Parse("{\"id\":"+i+"}"));
            }

            var content = await mg.SendMessageAsync(Domain, builder.GetMessage());
            content.ShouldNotBeNull();
        }

        [TestMethod]
        public async Task TestSendMessage()
        {
            var mg = new MessageService(ApiKey);

            //build a message
            var message = new MessageBuilder()
                .AddToRecipient(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "<NAME>"
                })
                .SetTestMode(true)
                .SetSubject("Plain text test")
                .SetFromAddress(new Recipient {Email = "<EMAIL>", DisplayName = "Mailgun C#"})
                .SetTextBody("This is a test")
                .GetMessage();

            var content = await mg.SendMessageAsync(Domain, message);
            content.ShouldNotBeNull();
        }

        [TestMethod]
        public async Task TestSendHtmlMessage()
        {
            var mg = new MessageService(ApiKey);

            //build a message
            var message = new MessageBuilder()
                .AddToRecipient(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "<NAME>"
                })
                .SetTestMode(true)
                .SetSubject("Html test")
                .SetFromAddress(new Recipient {Email = "<EMAIL>", DisplayName = "Mailgun C#"})
                .SetHtmlBody("<html><h1>Hello from the Mailgun C# library</h1></html>")
                .GetMessage();

            var content = await mg.SendMessageAsync(Domain, message);
            content.ShouldNotBeNull();
        }

        [TestMethod]
        public async Task TestSendAttachments()
        {
            var mg = new MessageService(ApiKey);

            //build a message
            var message = new MessageBuilder()
                .AddToRecipient(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "<NAME>"
                })
                .SetTestMode(true)
                .SetSubject("Attachment test")
                .SetFromAddress(new Recipient {Email = "<EMAIL>", DisplayName = "Mailgun C#"})
                .SetHtmlBody("<html><h1>I have an attachment</h1></html>")
                .AddAttachment(new FileInfo("C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg"))
                .GetMessage();

            var content = await mg.SendMessageAsync(Domain, message);
            content.ShouldNotBeNull();
        }

        [TestMethod]
        public async Task TestInlineImage()
        {
            var mg = new MessageService(ApiKey);

            //build a message
            var message = new MessageBuilder()
                .AddToRecipient(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "<NAME>"
                })
                .SetTestMode(true)
                .SetSubject("Inline image test")
                .SetFromAddress(new Recipient {Email = "<EMAIL>", DisplayName = "Mailgun C#"})
                .SetHtmlBody("<html>Inline image here: <img src=\"cid:Desert.jpg\"></html>")
                .AddInlineImage(new FileInfo("C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg"))
                .GetMessage();

            var content = await mg.SendMessageAsync(Domain, message);
            content.ShouldNotBeNull();
        }

        [TestMethod]
        public async Task TestKitchenSink()
        {
            var mg = new MessageService(ApiKey);

            //build a message
            var message = new MessageBuilder()
                .SetTestMode(true)
                .AddToRecipient(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "<NAME>"
                })
                .AddCcRecipient(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "Tester"
                })
                .AddBccRecipient(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "Tester"
                })
                .SetReplyToAddress(new Recipient
                {
                    Email = "<EMAIL>",
                    DisplayName = "Tester Reply"
                })
                .AddCustomData("Some Data", JObject.Parse("{\"test\":\"A test json object\"}"))
                .AddCustomHeader("X-My-Custom-Header", "Custom Header")
                .AddCustomParameter("CustomParam", "A custom parameter")
                .AddTag("Kitchen sink Tag")
                .AddCampaignId("fake_campaign_id")
                .SetClickTracking(true)
                .SetDkim(true)
                .SetOpenTracking(true)
                .SetDeliveryTime(DateTime.Now + TimeSpan.FromDays(1))
                .SetSubject("Kitchen Sink")
                .SetFromAddress(new Recipient {Email = "<EMAIL>", DisplayName = "Mailgun C#"})
                .SetTextBody("This is the text body")
                .SetHtmlBody("<html>Inline image here: <img src=\"cid:Desert.jpg\"></html>")
                .AddInlineImage(new FileInfo("C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg"))
                .AddAttachment(new FileInfo("C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg"))
                .GetMessage();

            var content = await mg.SendMessageAsync(Domain, message);
            content.ShouldNotBeNull();
        }
    }
}
{'fraction_non_alphanumeric': 0.11346240432237731, 'fraction_numerical': 0.004652558907399069, 'mean_word_length': 1.484989744545963, 'pattern_counts': {'":': 4, '<': 75, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6334273', 'n_tokens_mistral': 3571, 'n_tokens_neox': 3311, 'n_words': 728}