FitNesse / FitSharp - dynamically read ColumnFixture columns
I am using FitNesse / FitSharp (C #) for testing purposes.
I can create a normal device like ColumnFixtures, RowFixtures, DoFixtures, etc., but I'm not looking for a way to read columns and link them dynamically.
The reason for this is that I still have a huge number of Pojo objects in my own library, and I don't want to repeat all the members of the class again. So I am looking for a way to manage the column dynamically.
eg.
!|Create| pojoType | record | pojoName |
|Name | LastName | Address| Misc |
| a | b | c | d |
public class DynamicHandling : DoFixture () {
public void CreateRecord(string type, string name) {
var clazz = GetClazzOfType();
var headers = GetHeadersOfColumn();
var values = GetValuesOfColumn();
var pojo = DoBindingAndAssignValues(headers, rows, clazz);
// ... Continue with whatever e.g. ...
var name = pojo.Name;
var lastName = pojo.LastName;
var address = pojo.Address;
address.split(';') ...
}
}
Any idea?
+3
source to share
1 answer
Take a look at the source code for Compute fixture ( https://fitsharp.github.io/Fit/ComputeFixture.html ) and see if it helps.
You can write a tool that dynamically processes cells like this:
public class MyFixture: Interpreter {
public void Interpret(CellProcessor processor, Tree<Cell> table) {
new Traverse<Cell>()
.Rows.Header(row => FunctionThatDoesSomethingWithTheHeaderRow(row))
.Rows.Rest(row => FunctionThatDoesSomethingWithEachSubsequentRow(row))
.VisitTable(table);
}
...
}
Other sets of strings you can traverse - check the Traverse source code.
+3
source to share