Metamation Developer Notes

  • Developer Notes
  • Resource Map
  • Tools
    • Code Formatting
    • Configuring Git
    • Assignments
    • Testing with Windows Sandbox
    • Single Binary Applications
    • Self-Updating Applications
  • Flux Workflow
    • Flux Workflow
    • Flux Development Style Guide
    • Release notes for Flux
    • SonarCloud analysis for Flux
    • Build a Flux SDK Program
    • Shipping Flux
    • Flux.Test
      • BasicBendAuto Test
      • LaserAuto.cs Detailed Documentation
      • Laserexample:Test1
  • Technical Notes
    • File formats
      • .FX File Format
      • Au(Gold) streams
      • .GEO File Format
      • .LST File Format
      • .LST file - technology
      • .BNC File Format
      • .WAD Files: Flux Resource Packages
      • .Curl Files: ASCII config information
    • Folders App
      • Data\Bendtools
      • Data\Machines
    • FluxCode
      • Welcome & Repo Map
      • Architecture & System Context
      • Subsystem *Bend* (Press Brake)
      • Subsystem *BCell* (Bend Cell Automation)
      • API Maps
      • Data Model Catalog
      • Design Patterns -- A Reader's Guide
      • Tests and Golden Paths
      • Guided Code Tours
      • CAM Glossary with Code Mapping
      • Assignments
      • Flux Onboarding Handbook
    • Data flow
      • Part
        • Part.Dwg
        • Part.Load
        • Part.Load to Part.Dwg
      • BendTech.cs
      • Bend Technology
      • Laser Cutting Technology
    • LTS (Long term support mechanism)
    • Machine ID Scheme
  • FluxTester
    • Commands and Scripts
    • Command Cookbook
    • Script Commands
    • BendTooling.cs Test Inventory
    • LaserTooling.cs Test Steps
    • Fluxtester Recipe Book
    • Nesting.cs Overview
    • Nesting.cs Recipe Book
    • Job.cs Overview
    • Job.cs Recipe Book
  • Software license
  • 3d party software
    • Python
  • Documentation
    • Bento documentation
      • Structure of a Bento page
      • Attributes
    • Software
      • Software Requirement
      • Installation
      • Git workflow for documentation contributors
    • Quick start guide
    • Workflow
      • Roles and responsibilities
      • Analyze
      • Edit
      • Proofread
      • Pre-Publish
      • Publish
      • Release cycle
      • Information required for Documentation Team
      • Checklist for Documenters
    • Styleguide
    • Flavoring
    • Translation
      • Ordering translation for a new document
    • Citations
    • Annotation
Flux Workflow
/
Flux.Test
/
BasicBendAuto Test

BasicBendAuto Test

Overview

This document describes the BasicBendAuto test fixture and its helper methods from Test/Bend/BasicBendAuto.cs. It explains the purpose of each line in the main class and the associated static helpers used by the tests.

Test data is in X:\TData\Bend\Auto

Tip
open the .geo file and the dump file and compare the results

Source snippet (context)

namespace Flit;
#nullable enable

[TestFixture (4, "Basic bend auto-tooler tests", Module = "Bend", Subsystem = "AutoTool")]
class BasicBendAuto {
   [Test (82, "Tooling basic part: Bend_04.geo")]
   void Test1 () => Test ("Bend/Auto/Bend_04.geo");

   [Test (84, "Tooling basic part: Bend_01.geo")]
   void Test3 () => Test ("Bend/Auto/Bend_01.geo");

   [Test (85, "Tooling basic part: Bend_02_1000.geo")]
   void Test4 () => Test ("Bend/Auto/Bend_02_1000.geo");

...

   public static Part Test (string file, int idMachine = 13, bool infiniteInventory = true,
      bool ignoreToolHints = false, string? outfile = null,
      EDoFlags flags = EDoFlags.NoGAPAdjust, string? btools = null,
      bool openForEditing = false) {
      Part part = FX.LoadTestPart (file);
      if (part.Model == null) part.DoFoldTo3D ().Is (EResult.OK);
      BendTech.Make (part, BendMachine.Get (idMachine)).Is (EResult.OK);
      var tech = part.BendTech;
      if (tech.Inventory == tech.BMachine.Inventory)
         tech.Inventory = BToolLibrary.Get (1).MakeTestInventory (2);
      tech.Settings.InfiniteBInventory = infiniteInventory;
      tech.Settings.IgnoreBToolHints = ignoreToolHints;
      if (btools != null) tech.Inventory = BToolList.Load (FX.TestFile (btools));
      BendTooler.Process (part.BendTech, flags);
      outfile = outfile == null ? Path.ChangeExtension (file, ".txt") : FX.TestFile (outfile);
      if (openForEditing) part.OpenForEditing ();
      CheckDump (tech, outfile);
      return part;
   }

   public static void CheckDump (BendTech tech, string refFile) {
      string file = FX.TmpTestFile;
      refFile = FX.TestFile (refFile);
      using (StreamWriter sw = new (file)) tech.Dump (sw);
      Assert.AreTextFilesEqual (refFile, file);
   }
}

Line-by-line explanation

Below each numbered line or small group of lines from the main class is explained. The explanations focus on intent, side effects, and interactions with test infrastructure.

1: namespace Flit;
  • Declares the Flit namespace for the file. Groups related types and avoids global name collisions.

3-4: [TestFixture (4, "Basic bend auto-tooler tests", Module = "Bend", Subsystem = "AutoTool")]
  • Applies a test-framework attribute marking the BasicBendAuto class as a test fixture.

  • The parameters (e.g., 4, description, Module, Subsystem) are metadata used by the project’s test runner to categorize and identify the fixture.

5: class BasicBendAuto {
  • Begins the definition of the test fixture class named BasicBendAuto. Contains test methods and helpers.

6: ` [Test (82, "Tooling basic part: Bend_04.geo")]`
  • Attribute marking the next method as a test case.

  • First parameter 82 is the test id used by the project’s test harness; the string describes the test.

7: ` void Test1 () ⇒ Test ("Bend/Auto/Bend_04.geo");`
  • Single-line test method using expression-bodied syntax.

  • Calls the static helper Test(…​) to run tooling on the indicated test file.

  • Keeps the test method minimal; all heavy lifting delegated to Test.

(Tests 2–n follow the same pattern: attribute with id and description, and a one-line method calling Test with a file path.) - Each test method pairs an id + description attribute with a minimal body that invokes the shared Test helper. This avoids duplicating setup and verification logic across tests.

21-40: public static Part Test (string file, int idMachine = 13, bool infiniteInventory = true, bool ignoreToolHints = false, string? outfile = null, EDoFlags flags = EDoFlags.NoGAPAdjust, string? btools = null, bool openForEditing = false) {
  • Declares a public static helper method used by all the test methods.

  • Parameters:

  • file: relative path to the test input file (DXF/.geo/.fx, etc.).

  • idMachine: machine id to use (default 13).

  • infiniteInventory: if true, simulate unlimited tools in inventory (default true).

  • ignoreToolHints: if true, ignore hints embedded in the model about tooling.

  • outfile: optional expected output file path (if null, derived from input filename).

  • flags: processing flags controlling pre-processing/accuracy; default is EDoFlags.NoGAPAdjust.

  • btools: optional override tool-list file.

  • openForEditing: if true, leaves the part open for manual inspection.

41: ` Part part = FX.LoadTestPart (file);`
  • Loads the test part from the provided file using a test helper FX.LoadTestPart.

  • Returns a domain Part object representing the model to test.

42: ` if (part.Model == null) part.DoFoldTo3D ().Is (EResult.OK);`
  • If the loaded Part does not already have a 3D model, call DoFoldTo3D() to generate/fold it.

  • The .Is(EResult.OK) call asserts the result equals EResult.OK — a lightweight assertion idiom in this codebase.

43: ` BendTech.Make (part, BendMachine.Get (idMachine)).Is (EResult.OK);`
  • Constructs or computes BendTech for the part targeting the machine returned by BendMachine.Get(idMachine).

  • .Is(EResult.OK) asserts the operation succeeded. BendTech.Make prepares tooling, stations, and other bend-specific data.

44: ` var tech = part.BendTech;`
  • Short local to hold the computed BendTech object for convenient access in subsequent steps.

45-46: ` if (tech.Inventory == tech.BMachine.Inventory) tech.Inventory = BToolLibrary.Get (1).MakeTestInventory (2);`
  • Ensures the BendTech has a testable inventory distinct from the machine default:

  • If the tech.Inventory references the machine’s default inventory, replace it with a test inventory created from BToolLibrary.Get(1).

  • MakeTestInventory(2) likely creates a small inventory with 2 copies or 2 sets for deterministic testing.

47: ` tech.Settings.InfiniteBInventory = infiniteInventory;`
  • Sets a boolean testing setting on the BendTech to simulate unlimited stock of tools when true. Useful to avoid inventory-limited failures during tests.

48: ` tech.Settings.IgnoreBToolHints = ignoreToolHints;`
  • Controls whether tooling hints embedded in the model are honored. When true, hints are ignored so the auto-tooler decides without model-supplied recommendations.

49: ` if (btools != null) tech.Inventory = BToolList.Load (FX.TestFile (btools));`
  • If the test specified a btools path, load that tool list and use it as the tech.Inventory, overriding prior inventory adjustments.

  • FX.TestFile converts a logical test file path to a filesystem path.

50: ` BendTooler.Process (part.BendTech, flags);`
  • Runs the core auto-tooling algorithm BendTooler.Process on the prepared BendTech.

  • flags controls behavior such as alignment, gap adjustments, and other processing nuances.

51: ` outfile = outfile == null ? Path.ChangeExtension (file, ".txt") : FX.TestFile (outfile);`
  • Determine the expected output reference file:

  • If outfile was not provided, derive it by replacing the input file extension with .txt (e.g., Bend_04.geo → Bend_04.txt).

  • If outfile was provided, convert it to the actual test reference path using FX.TestFile.

52: ` if (openForEditing) part.OpenForEditing ();`
  • If openForEditing is true, open the resulting Part in an editor or UI for manual inspection (useful for debugging failing tests).

53: ` CheckDump (tech, outfile);`
  • Call CheckDump to serialize the BendTech to a temporary file and compare it to the reference outfile.

  • This is the primary assertion: produced tooling dump must match the expected text dump.

54: ` return part;`
  • Return the Part instance so callers/tests can make further checks if needed.

55: ` }`
  • End of Test method.

56: ` public static void CheckDump (BendTech tech, string refFile) {`
  • Declare a helper that writes the current tooling state to a temporary file and compares it with a reference text file.

57: ` string file = FX.TmpTestFile;`
  • Acquire a temporary file path from test helper FX.TmpTestFile to hold the dump output.

58: ` refFile = FX.TestFile (refFile);`
  • Resolve the provided refFile logical path to an absolute test-file path used for comparison.

59: ` using (StreamWriter sw = new (file)) tech.Dump (sw);`
  • Open a StreamWriter to the temp file and call tech.Dump(sw) to serialize the BendTech contents (tools, stations, sequence, settings) to text.

  • using ensures the writer (and file descriptor) is disposed/closed.

60: ` Assert.AreTextFilesEqual (refFile, file);`
  • Compare the reference file and produced temp file text content via the project’s Assert.AreTextFilesEqual helper.

  • If they differ, the test fails and the diff indicates tooling/regression.

61: ` }`
  • End of CheckDump method.

62: }
  • End of BasicBendAuto class.

Example dump from GEO04.txt

Matl=1.0038  Thick=2  MC=13:"5130X 6A B23"
4, 2, 8, 6
'OW202/S R1/28 H220'  [500+30]  X=0
'EV005 W16/30 R1.6'  [500+30]  X=0
Open=110
G1  (-308,54,-8)  Surf=4
G2  (267,70,-8)  Surf=1
Status=RotateR
Open=110  HBox=101
G1  (-308,54,-8)  Surf=4
G2  (267,70,-8)  Surf=1
Status=RotateR
Open=110  HBox=101
G1  (-308,54,-8)  Surf=4
G2  (267,70,-8)  Surf=1
Status=RotateR
Open=110  HBox=101
G1  (-308,54,-8)  Surf=4
G2  (267,70,-8)  Surf=1
Status=OK

Contents

  • Overview
  • Source snippet (context)
  • Line-by-line explanation
  • Example dump from GEO04.txt
Flux.Test LaserAuto.cs Detailed Documentation

      Copyright © 2025 TRUMPF Metamation. All rights reserved.

    Compiled by Bento