diff options
author | Robin J <me@rbin.co> | 2014-02-17 16:11:42 +0000 |
---|---|---|
committer | Robin J <me@rbin.co> | 2014-02-17 16:11:42 +0000 |
commit | 849ece5e6b93b0fb965f6d52a78958ef1a014f9a (patch) | |
tree | 08652475fbd7e8adeb26f816a3bc80259c4156bc /SendGrid/Tests/Transport/TestWeb.cs | |
parent | 66094a4e8321e834229a70084a6235360e52155c (diff) | |
parent | 9ab26dc5e0057ba3c9017175196b1b96a0a53deb (diff) | |
download | sendgrid-csharp-849ece5e6b93b0fb965f6d52a78958ef1a014f9a.zip sendgrid-csharp-849ece5e6b93b0fb965f6d52a78958ef1a014f9a.tar.gz sendgrid-csharp-849ece5e6b93b0fb965f6d52a78958ef1a014f9a.tar.bz2 |
Merge pull request #44 from Xerax/master
Code clean-up and tweaks
Diffstat (limited to 'SendGrid/Tests/Transport/TestWeb.cs')
-rw-r--r-- | SendGrid/Tests/Transport/TestWeb.cs | 109 |
1 files changed, 55 insertions, 54 deletions
diff --git a/SendGrid/Tests/Transport/TestWeb.cs b/SendGrid/Tests/Transport/TestWeb.cs index d87a423..18753b4 100644 --- a/SendGrid/Tests/Transport/TestWeb.cs +++ b/SendGrid/Tests/Transport/TestWeb.cs @@ -1,66 +1,67 @@ -using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
-using System.Text;
using Moq;
using NUnit.Framework;
using SendGridMail;
namespace Tests.Transport
{
- [TestFixture]
- class TestWeb
- {
- [Test]
- public void TestFetchFileBodies()
- {
- var test = Web.GetInstance(new NetworkCredential("foo", "bar"));
- var message = new Mock<ISendGrid>();
- message.SetupProperty(foo => foo.Attachments, null);
- var result = test.FetchFileBodies(message.Object);
- Assert.AreEqual(0, result.Count);
+ [TestFixture]
+ internal class TestWeb
+ {
+ private const string TestUsername = "usr";
+ private const string TestPassword = "psswd";
- message.SetupProperty(foo => foo.Attachments, new string[] {"foo", "bar", "raz"});
- result = test.FetchFileBodies(message.Object);
- Assert.AreEqual(3, result.Count);
- Assert.AreEqual(result[0].Key, "foo");
- Assert.AreEqual(result[1].Key, "bar");
- Assert.AreEqual(result[2].Key, "raz");
- Assert.AreEqual(result[0].Value.Name, "foo");
- Assert.AreEqual(result[1].Value.Name, "bar");
- Assert.AreEqual(result[2].Value.Name, "raz");
- }
+ [Test]
+ public void TestFetchFileBodies()
+ {
+ var test = Web.GetInstance(new NetworkCredential(TestUsername, TestPassword));
+ var message = new Mock<ISendGrid>();
+ message.SetupProperty(foo => foo.Attachments, null);
+ var result = test.FetchFileBodies(message.Object);
+ Assert.AreEqual(0, result.Count);
- [Test]
- public void TestFetchFormParams()
- {
- var bar = Web.GetInstance(new NetworkCredential("usr", "psswd"));
- var message = SendGrid.GetInstance();
- message.AddTo("foo@bar.com");
- message.AddCc("cc@bar.com");
- message.AddBcc("bcc@bar.com");
- message.From = new MailAddress("from@raz.com");
- message.Subject = "subject";
- message.Text = "text";
- message.Html = "html";
- message.AddHeaders(new Dictionary<string, string>{{"headerkey", "headervalue"}});
- message.Header.SetCategory("cat");
+ message.SetupProperty(foo => foo.Attachments, new[] {"foo", "bar", "raz"});
+ result = test.FetchFileBodies(message.Object);
+ Assert.AreEqual(3, result.Count);
+ Assert.AreEqual(result[0].Key, "foo");
+ Assert.AreEqual(result[1].Key, "bar");
+ Assert.AreEqual(result[2].Key, "raz");
+ Assert.AreEqual(result[0].Value.Name, "foo");
+ Assert.AreEqual(result[1].Value.Name, "bar");
+ Assert.AreEqual(result[2].Value.Name, "raz");
+ }
- var result = bar.FetchFormParams(message);
- Assert.True(result.Any(r => r.Key == "api_user" && r.Value == "usr"));
- Assert.True(result.Any(r => r.Key == "api_key" && r.Value == "psswd"));
- Assert.True(result.Any(r => r.Key == "to[]" && r.Value == "foo@bar.com"));
- Assert.True(result.Any(r => r.Key == "cc[]" && r.Value == "cc@bar.com"));
- Assert.True(result.Any(r => r.Key == "bcc[]" && r.Value == "bcc@bar.com"));
- Assert.True(result.Any(r => r.Key == "from" && r.Value == "from@raz.com"));
- Assert.True(result.Any(r => r.Key == "subject" && r.Value == "subject"));
- Assert.True(result.Any(r => r.Key == "text" && r.Value == "text"));
- Assert.True(result.Any(r => r.Key == "html" && r.Value == "html"));
- Assert.True(result.Any(r => r.Key == "headers" && r.Value == "{\"headerkey\":\"headervalue\"}"));
- Assert.True(result.Any(r => r.Key == "x-smtpapi" && r.Value == "{\"category\" : \"cat\"}"));
- Assert.True(result.Any(r => r.Key == "html" && r.Value == "html"));
- }
- }
-}
+ [Test]
+ public void TestFetchFormParams()
+ {
+ var bar = Web.GetInstance(new NetworkCredential(TestUsername, TestPassword));
+ var message = SendGrid.GetInstance();
+ message.AddTo("foo@bar.com");
+ message.AddCc("cc@bar.com");
+ message.AddBcc("bcc@bar.com");
+ message.From = new MailAddress("from@raz.com");
+ message.Subject = "subject";
+ message.Text = "text";
+ message.Html = "html";
+ message.AddHeaders(new Dictionary<string, string> {{"headerkey", "headervalue"}});
+ message.Header.SetCategory("cat");
+
+ var result = bar.FetchFormParams(message);
+ Assert.True(result.Any(r => r.Key == "api_user" && r.Value == TestUsername));
+ Assert.True(result.Any(r => r.Key == "api_key" && r.Value == TestPassword));
+ Assert.True(result.Any(r => r.Key == "to[]" && r.Value == "foo@bar.com"));
+ Assert.True(result.Any(r => r.Key == "cc[]" && r.Value == "cc@bar.com"));
+ Assert.True(result.Any(r => r.Key == "bcc[]" && r.Value == "bcc@bar.com"));
+ Assert.True(result.Any(r => r.Key == "from" && r.Value == "from@raz.com"));
+ Assert.True(result.Any(r => r.Key == "subject" && r.Value == "subject"));
+ Assert.True(result.Any(r => r.Key == "text" && r.Value == "text"));
+ Assert.True(result.Any(r => r.Key == "html" && r.Value == "html"));
+ Assert.True(result.Any(r => r.Key == "headers" && r.Value == "{\"headerkey\":\"headervalue\"}"));
+ Assert.True(result.Any(r => r.Key == "x-smtpapi" && r.Value == "{\"category\" : \"cat\"}"));
+ Assert.True(result.Any(r => r.Key == "html" && r.Value == "html"));
+ }
+ }
+}
\ No newline at end of file |