aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.UnitTesting
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2019-05-08 08:58:30 +0300
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2019-05-08 08:58:30 +0300
commit965977ef625be8fe7bea02121403fbf9041fd43a (patch)
tree505295f4854e281f807116873f3d60ef75c7fd4f /Software/Visual_Studio/Tango.UnitTesting
parent415eff697fc2a3eb210b833a2b2d28bcc46c0e26 (diff)
parent03332f71a1ebc983cc15499912f198cf2444bec6 (diff)
downloadTango-965977ef625be8fe7bea02121403fbf9041fd43a.tar.gz
Tango-965977ef625be8fe7bea02121403fbf9041fd43a.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting')
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/App.config20
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs97
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj22
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/packages.config6
4 files changed, 135 insertions, 10 deletions
diff --git a/Software/Visual_Studio/Tango.UnitTesting/App.config b/Software/Visual_Studio/Tango.UnitTesting/App.config
index 1261bcbe9..0490d020e 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/App.config
+++ b/Software/Visual_Studio/Tango.UnitTesting/App.config
@@ -63,7 +63,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
@@ -71,27 +71,27 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
+ <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" />
@@ -107,7 +107,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Algorithms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
+ <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
@@ -117,6 +117,10 @@
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.1.1.2" />
+ </dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
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..9465676ef
--- /dev/null
+++ b/Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs
@@ -0,0 +1,97 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using SendGrid;
+using SendGrid.Helpers.Mail;
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.PMR.TCC;
+
+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);
+ }
+
+ [TestMethod]
+ public void Send_Template_Email()
+ {
+ var client = new SendGridClient(KEY);
+ SendGridMessage msg = new SendGridMessage();
+ msg.SetFrom("test@example.com");
+ msg.AddTo("roy.mail.net@gmail.com");
+ msg.Subject = "SnapMatch Color Result";
+ msg.SetTemplateId("d-619b8adc604d4f6fa486d7bbc9e3c2cc");
+
+ Bitmap rect = new Bitmap(80, 80);
+ using (Graphics g = Graphics.FromImage(rect))
+ {
+ g.Clear(Color.FromArgb(255, 0, 0));
+ }
+
+ String image64 = String.Empty;
+
+ using (MemoryStream ms = new MemoryStream())
+ {
+ rect.Save(ms, ImageFormat.Jpeg);
+ ms.Position = 0;
+ image64 = Convert.ToBase64String(ms.ToArray());
+ }
+
+ var dynamicTemplateData = new ExampleTemplateData
+ {
+ Name = "Roy",
+ Message = "This is my personal note...",
+ ImageSource = image64,
+ };
+
+ msg.SetTemplateData(dynamicTemplateData);
+
+
+ DetectionColorFile file = new DetectionColorFile();
+ file.RawColor = new DetectionColor() { R = 10, G = 20, B = 30 };
+ file.ProcessedColor = new DetectionColor() { R = 11, G = 21, B = 31 };
+
+ var base64 = Convert.ToBase64String(file.ToBytes());
+ msg.AddAttachment("SnapMatch Color.tcc", base64, "application/octet-stream");
+
+ var result = client.SendEmailAsync(msg).GetAwaiter().GetResult();
+
+ Assert.IsTrue(result.StatusCode == HttpStatusCode.Accepted);
+ }
+
+ public class ExampleTemplateData
+ {
+ public String Name { get; set; }
+ public String ImageSource { get; set; }
+ public String Message { get; set; }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj
index 6fd23451d..c7a2cc451 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj
+++ b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj
@@ -84,6 +84,9 @@
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
+ <Reference Include="SendGrid, Version=9.11.0.0, Culture=neutral, PublicKeyToken=4f047e93159395ca, processorArchitecture=MSIL">
+ <HintPath>..\packages\Sendgrid.9.11.0\lib\net452\SendGrid.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
@@ -103,10 +106,24 @@
<Private>True</Private>
</Reference>
<Reference Include="System.Drawing" />
- <Reference Include="System.Net.Http" />
+ <Reference Include="System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\packages\System.Net.Http.4.3.3\lib\net46\System.Net.Http.dll</HintPath>
+ </Reference>
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
</Reference>
+ <Reference Include="System.Security.Cryptography.Algorithms, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
+ </Reference>
<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
</Reference>
@@ -126,6 +143,7 @@
<Compile Include="MachineStudio\MachineStudio_TST.cs" />
<Compile Include="Pulse\Pulse_TST.cs" />
<Compile Include="RemoteRunner_TST.cs" />
+ <Compile Include="SendGrid\SendGrid_TST.cs" />
<Compile Include="SQLExaminer\SQLExaminer_TST.cs" />
<Compile Include="Core\TemporaryManager_TST.cs" />
<Compile Include="TCC\TCC_TST.cs" />
@@ -289,7 +307,7 @@
<Import Project="..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets')" />
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
+ <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/Tango.UnitTesting/packages.config b/Software/Visual_Studio/Tango.UnitTesting/packages.config
index e3fc2d3b6..f6feb1f49 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/packages.config
+++ b/Software/Visual_Studio/Tango.UnitTesting/packages.config
@@ -11,9 +11,15 @@
<package id="MSTest.TestAdapter" version="1.1.11" targetFramework="net45" />
<package id="MSTest.TestFramework" version="1.1.11" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" />
+ <package id="Sendgrid" version="9.11.0" targetFramework="net461" />
<package id="System.Data.SQLite" version="1.0.108.0" targetFramework="net46" />
<package id="System.Data.SQLite.Core" version="1.0.108.0" targetFramework="net46" />
<package id="System.Data.SQLite.EF6" version="1.0.108.0" targetFramework="net46" />
<package id="System.Data.SQLite.Linq" version="1.0.108.0" targetFramework="net46" />
+ <package id="System.Net.Http" version="4.3.3" targetFramework="net461" />
+ <package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net461" />
+ <package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net461" />
+ <package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net461" />
+ <package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net461" />
<package id="TestStack.White" version="0.13.3" targetFramework="net46" />
</packages> \ No newline at end of file