diff options
author | Brandon West <brawest@gmail.com> | 2012-07-13 15:57:31 -0600 |
---|---|---|
committer | Brandon West <brawest@gmail.com> | 2012-07-13 15:57:31 -0600 |
commit | 546ce43c7f7321aadf49b797cc876c28adf1e098 (patch) | |
tree | 4e1a0f81e4797a1388f7a377eac7c4c146417f95 /SendGrid/Tests | |
parent | 9da0d78cacd7530dbb1c6b26353bc22a90dea2d9 (diff) | |
parent | 2bec2e3d78b5d993e5daa7b8d0e5edfd0c03034d (diff) | |
download | sendgrid-csharp-546ce43c7f7321aadf49b797cc876c28adf1e098.zip sendgrid-csharp-546ce43c7f7321aadf49b797cc876c28adf1e098.tar.gz sendgrid-csharp-546ce43c7f7321aadf49b797cc876c28adf1e098.tar.bz2 |
merge streaming-attachments branch
Diffstat (limited to 'SendGrid/Tests')
-rwxr-xr-x | SendGrid/Tests/TestStreamedFileBody.cs | 35 | ||||
-rwxr-xr-x | SendGrid/Tests/Tests.csproj | 5 |
2 files changed, 40 insertions, 0 deletions
diff --git a/SendGrid/Tests/TestStreamedFileBody.cs b/SendGrid/Tests/TestStreamedFileBody.cs new file mode 100755 index 0000000..60d43b8 --- /dev/null +++ b/SendGrid/Tests/TestStreamedFileBody.cs @@ -0,0 +1,35 @@ +using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using NUnit.Framework;
+using SendGridMail;
+
+namespace Tests
+{
+ [TestFixture]
+ public class TestStreamedFileBody
+ {
+ [Test]
+ public void TestGetContent()
+ {
+ var name = "foo";
+ var file = "bar";
+ var boundary = "raz";
+
+ var memoryStream = new MemoryStream();
+ var stream = new StreamWriter(memoryStream);
+ stream.Write(file);
+ stream.Flush();
+ stream.Close();
+
+ var streamedFile = new StreamedFileBody(memoryStream, name);
+ var bytes = streamedFile.GetContent(boundary);
+ var result = System.Text.Encoding.ASCII.GetString(bytes);
+ var expected = "--raz\r\nContent-Disposition: form-data; name=\"files[foo]\"; filename=\"foo\"\r\nContent-Type: image/png\r\n\r\nbar\r\n";
+ Assert.AreEqual(expected, result, "message formated correctly");
+
+ }
+ }
+}
diff --git a/SendGrid/Tests/Tests.csproj b/SendGrid/Tests/Tests.csproj index c75563a..cdfd9b7 100755 --- a/SendGrid/Tests/Tests.csproj +++ b/SendGrid/Tests/Tests.csproj @@ -31,6 +31,10 @@ <WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="CodeScales.Http, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\SendGridMail\lib\CodeScales.Http.dll</HintPath>
+ </Reference>
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
@@ -57,6 +61,7 @@ <Compile Include="TestJsonUtils.cs" />
<Compile Include="TestSendgrid.cs" />
<Compile Include="TestSendgridMessageSetup.cs" />
+ <Compile Include="TestStreamedFileBody.cs" />
<Compile Include="TestTreeNode.cs" />
<Compile Include="TestUtils.cs" />
<Compile Include="Transport\TestWeb.cs" />
|