Skip to content

Commit 6a5c673

Browse files
author
Sven Erb
committed
Added test for parsing to GCode.
1 parent 0b5a46f commit 6a5c673

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

ReaderWriter/UnitTests/GCodeTest.cs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,38 @@ You should have received a copy of the GNU Lesser General Public
3131
using OpenVectorFormat.GCodeReaderWriter;
3232
using System.IO;
3333

34-
namespace UnitTests
34+
namespace OpenVectorFormat.ReaderWriter.UnitTests
3535
{
3636
[TestClass]
3737
public class GCodeTest
3838
{
39-
public static DirectoryInfo dir = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "TestFiles/gcode"));
39+
public static DirectoryInfo dir = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "TestFiles"));
40+
41+
[DynamicData("GCodeFiles")]
4042
[TestMethod]
41-
public void TestGetJobShell()
43+
public void TestGCodeFiles(FileInfo fileName)
44+
{
45+
var gCodeReader = new GCodeReader();
46+
47+
string testCommand = File.ReadAllLines(fileName.FullName)[21];
48+
GCodeState gCodeState = new GCodeState(testCommand);
49+
50+
LinearInterpolationCmd assertCmd = new LinearInterpolationCmd(PrepCode.G, 1, new Dictionary<char, float> { { 'F', 1800 }, { 'X', 110.414f }, { 'Y', 94.025f }, { 'E', 0.02127f } });
51+
Assert.AreEqual(gCodeState.gCodeCommand.gCode, assertCmd.gCode );
52+
Assert.AreEqual(gCodeState.gCodeCommand.GetType(), assertCmd.GetType());
53+
}
54+
public static List<object[]> GCodeFiles
4255
{
43-
GCodeReader reader = new GCodeReader();
44-
string filename = Directory.GetCurrentDirectory() + "/pumpkin_basic.gcode";
45-
reader.OpenJob(filename);
46-
var jobShell = reader.JobShell;
47-
Assert.IsNotNull(jobShell);
56+
get
57+
{
58+
FileInfo[] testFiles = dir.GetFiles("*.gcode"); //getting all .cli files
59+
List<object[]> files = new List<object[]>(testFiles.Length);
60+
for (int i = 0; i < testFiles.Length; i++)
61+
{
62+
files.Add(new object[] { testFiles[i] });
63+
}
64+
return files;
65+
}
4866
}
4967
}
5068
}

0 commit comments

Comments
 (0)