diff options
| author | Avi Levkovich <avi@twine-s.com> | 2019-05-12 10:11:17 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2019-05-12 10:11:17 +0300 |
| commit | caa033747fa1703480a09b13230e8e4266e292d3 (patch) | |
| tree | a79282ca7d5a34df90431f414ef5bce4ede10319 /Software/Visual_Studio/Tango.UnitTesting | |
| parent | 334e162b648f0861ac5e862325dbbaeab46f005f (diff) | |
| parent | 78e431cbb1e3b92f7b831bd20d6dc5690e4fbfa4 (diff) | |
| download | Tango-caa033747fa1703480a09b13230e8e4266e292d3.tar.gz Tango-caa033747fa1703480a09b13230e8e4266e292d3.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting')
| -rw-r--r-- | Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs | 42 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs | 37 |
2 files changed, 79 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs index 073841997..65bb31208 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs @@ -82,5 +82,47 @@ namespace Tango.UnitTesting.Pulse Helper.ShowInExplorer(imgFile); } + + [TestMethod] + public void Create_Twn_Sample_File() + { + String abcFile = Path.Combine(Helper.GetResourcePath(), "Pulse", "ABC.dst"); + + TwnFile twnFile = new TwnFile(); + twnFile.Name = "My design"; + twnFile.NumberOfCopies = 1; + twnFile.MediaID = 0; + twnFile.SpoolingMethod = SpoolingMethods.SpoolPerSegment; + + Bitmap thumbnail = new Bitmap(1280, 720); + using (Graphics g = Graphics.FromImage(thumbnail)) + { + g.Clear(Color.Gray); + g.DrawString("My design", new Font(new FontFamily("Arial"), 70), Brushes.Red, 1280 / 2, 720 / 2); + } + twnFile.Thumbnail = thumbnail; + + twnFile.EmbroideryFileFormat = "dst"; + twnFile.EmbroideryFile = File.ReadAllBytes(abcFile); + + //Add gradient segment. + TwnSegment gradientSegment = new TwnSegment(); + gradientSegment.Length = 100 * 10; //10 meters. + gradientSegment.BrushStops.Add(new TwnStop(255, 0, 0, 0)); //0% + gradientSegment.BrushStops.Add(new TwnStop(0, 0, 255, 1)); //100% + twnFile.Segments.Add(gradientSegment); + + //Add solid segment. + TwnSegment solidSegment = new TwnSegment(); + solidSegment.Length = 100 * 20; //20 meters. + solidSegment.BrushStops.Add(new TwnStop(0, 255, 0, 0)); + twnFile.Segments.Add(solidSegment); + + var twnFilePath = TemporaryManager.Default.CreateFile(".twn"); + + twnFile.ToFile(twnFilePath); + + twnFilePath.Display(); + } } } diff --git a/Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs index 785fa42bf..ca0ba1143 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs @@ -3,10 +3,14 @@ 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 { @@ -35,5 +39,38 @@ namespace Tango.UnitTesting.SendGrid 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"); + + var dynamicTemplateData = new + { + Message = "This is my personal note...", + R = 0, + G = 255, + B = 0, + }; + + 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); + } } } |
