예제 #1
0
        protected void RunGCodeTest(string testName, string testFileName, Action <ConfigSettings> action = null)
        {
            if (!buildControlFiles && testName == "baseline")
            {
                return;
            }

            if (!buildControlFiles && baseLineText == null)
            {
                baseLineText = File.ReadAllText(TestUtilities.GetControlGCodePath("baseline"));
            }

            string controlPath = TestUtilities.GetControlGCodePath(testName);

            string outputPath = (buildControlFiles) ? controlPath : TestUtilities.GetTempGCodePath(testName);

            var configSettings = new ConfigSettings();

            action?.Invoke(configSettings);

            if (testFileName == null)
            {
                testFileName = "primitives.stl";
            }

            ProcessGCode(configSettings, TestUtilities.GetStlPath(testFileName), outputPath);

            if (!buildControlFiles)
            {
                string testResults = File.ReadAllText(outputPath);

                Assert.AreNotEqual(controlPath, outputPath, "Control and test paths must differ");
                Assert.AreNotEqual(testResults, baseLineText, "Test does not vary from baseline: " + testName);
                Assert.AreEqual(
                    File.ReadAllText(controlPath),
                    testResults,
                    "Test varies from expected control output: " + testName);
            }
        }