Jeremy Miller shows how Bobcat's decision tables express a business rules table as plain Markdown, one row method and several asserted outputs per row. A made-up loan underwriting policy demonstrates how an off-by-one comparison gets caught at the boundaries.
Key points
- The table is a C# raw string literal read by `StepTable` through implicit conversion, so a Markdown table pastes in unchanged.
- A `[Then]` method is the step helper; the Bobcat.Generators source generator picks it up at compile time with no base class or registration.
- Ordinary parameters bind to input columns, `out` parameters become output columns, and the returned value is checked against the unclaimed column.
- Sixteen rows produce 48 assertions, because `Decision`, `Rate` and `Guarantor` are each verified per row.
- A broken comparison shows expected versus actual per cell, and `bobcat run --verbose` or `--html` prints the table as a report.
- Rows sit on the thresholds themselves (579/580, 669/670, 739/740, 36/37, 43/44, 30000/30001) instead of covering every combination.
Real-world use
- A loan underwriting rule that approves, declines or refers an application based on credit score, debt to income and loan size
- Data-heavy business rules where a domain expert reviews the inputs and expected outputs as a Markdown table
This summary was generated by the agent from the original post on JasperFx (Critter Stack) Blog. The full text and all rights belong to its author and publisher. Go to original