aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.UnitTesting
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-05-16 11:58:10 +0300
committerShlomo Hecht <shlomo@twine-s.com>2019-05-16 11:58:10 +0300
commit30fcfa4100a9d00e887c6e17e32e427b05296ce7 (patch)
tree0810375ae9424acca748b6538e7d1cf706dbb3a4 /Software/Visual_Studio/Tango.UnitTesting
parent62b3546679aab27fc35b0955608c24ad37619258 (diff)
parent4fdb3d2406b16a95e15fe24d6f562e666b3258af (diff)
downloadTango-30fcfa4100a9d00e887c6e17e32e427b05296ce7.tar.gz
Tango-30fcfa4100a9d00e887c6e17e32e427b05296ce7.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/Pulse/Pulse_TST.cs136
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs29
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/TCC/TCC_TST.cs3
3 files changed, 140 insertions, 28 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..9951d8d10 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs
+++ b/Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs
@@ -82,5 +82,141 @@ 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();
+ }
+
+ [TestMethod]
+ public void Compose_Artificial_Twn_File()
+ {
+ String dstFile = Path.Combine(Helper.GetResourcePath(), "Pulse", "TCap", "T-CAP.dst");
+ String imgSolidFile = Path.Combine(Helper.GetResourcePath(), "Pulse", "TCap", "T_Cap_Solid.png");
+ String imgGradientFile = Path.Combine(Helper.GetResourcePath(), "Pulse", "TCap", "T_Cap.png");
+
+ TwnFile twnFile = new TwnFile();
+ twnFile.Version = 1f;
+ twnFile.Name = "T Cap Solid";
+ twnFile.NumberOfCopies = 1;
+ twnFile.MediaID = 0;
+ twnFile.SpoolingMethod = SpoolingMethods.SingleSpool;
+
+ twnFile.EmbroideryFile = File.ReadAllBytes(dstFile);
+ twnFile.EmbroideryFileFormat = "dst";
+
+
+ //Generate solid.
+ Bitmap thumbnail = new Bitmap(imgSolidFile);
+ twnFile.Thumbnail = thumbnail;
+
+ twnFile.Segments.Add(CreateSolidSegment(10, 252, 224, 87));
+ twnFile.Segments.Add(CreateSolidSegment(10, 251, 168, 45));
+ twnFile.Segments.Add(CreateSolidSegment(10, 237, 19, 117));
+ twnFile.Segments.Add(CreateSolidSegment(10, 234, 89, 56));
+
+ var tempFolder = TemporaryManager.Default.CreateFolder();
+ twnFile.ToFile(Path.Combine(tempFolder, "t-cap solid.twn"));
+
+ twnFile.Segments.Clear();
+
+ //Generate gradient.
+ twnFile.Name = "T Cap Gradient";
+
+ thumbnail = new Bitmap(imgGradientFile);
+ twnFile.Thumbnail = thumbnail;
+
+ twnFile.Segments.Add(CreateGradientSegment(10, 237, 19, 117, 251, 168, 45));
+ twnFile.Segments.Add(CreateGradientSegment(10, 237, 19, 117, 251, 168, 45));
+ twnFile.Segments.Add(CreateGradientSegment(10, 139, 48, 145, 251, 168, 45));
+ twnFile.Segments.Add(CreateGradientSegment(10, 139, 48, 145, 242, 141, 172));
+
+ twnFile.ToFile(Path.Combine(tempFolder, "t-cap gradient.twn"));
+
+ tempFolder.Display();
+ }
+
+ private TwnSegment CreateSolidSegment(float meter, byte r, byte g, byte b)
+ {
+ var segment = new TwnSegment()
+ {
+ Length = meter * 100,
+ BrushStops = new List<TwnStop>()
+ {
+ new TwnStop()
+ {
+ R = r,
+ G = g,
+ B = b
+ },
+ }
+ };
+
+ return segment;
+ }
+
+ private TwnSegment CreateGradientSegment(float meter, byte r1, byte g1, byte b1, byte r2, byte g2, byte b2)
+ {
+ var segment = new TwnSegment()
+ {
+ Length = meter * 100,
+ BrushStops = new List<TwnStop>()
+ {
+ new TwnStop()
+ {
+ R = r1,
+ G = g1,
+ B = b1,
+ Offset = 0
+ },
+ new TwnStop()
+ {
+ R = r2,
+ G = g2,
+ B = b2,
+ Offset = 1
+ },
+ }
+ };
+
+ return segment;
+ }
}
}
diff --git a/Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs
index 9465676ef..ca0ba1143 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs
+++ b/Software/Visual_Studio/Tango.UnitTesting/SendGrid/SendGrid_TST.cs
@@ -50,26 +50,12 @@ namespace Tango.UnitTesting.SendGrid
msg.Subject = "SnapMatch Color Result";
msg.SetTemplateId("d-619b8adc604d4f6fa486d7bbc9e3c2cc");
- Bitmap rect = new Bitmap(80, 80);
- using (Graphics g = Graphics.FromImage(rect))
+ var dynamicTemplateData = new
{
- 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,
+ R = 0,
+ G = 255,
+ B = 0,
};
msg.SetTemplateData(dynamicTemplateData);
@@ -86,12 +72,5 @@ namespace Tango.UnitTesting.SendGrid
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/TCC/TCC_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/TCC/TCC_TST.cs
index 59237b4a0..c4332a146 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/TCC/TCC_TST.cs
+++ b/Software/Visual_Studio/Tango.UnitTesting/TCC/TCC_TST.cs
@@ -32,7 +32,6 @@ namespace Tango.UnitTesting.TCC
{
DetectionInput input = new DetectionInput()
{
- Number = 5,
Columns = 10,
Rows = 11,
TargetIndex = 99,
@@ -78,8 +77,6 @@ namespace Tango.UnitTesting.TCC
}
Helper.ShowInExplorer(benchmarksCsvFile);
-
- Assert.IsTrue(output.Number == 15);
}
}
}