Search code examples
c#fitnessefitnesse-slim

Fitnesse evaluate Symbol in Cell


I want to evaluate a Symbol within a Cell in Fitnesse with C#. The problem is that i am able to evaluate the Symbol isolated in a single Cell. If I attach for example a String, the Symbol won´t be evaluated.

The Example:

// the ArticleNumber-Symbol holds some value but won´t be evaluated
!| DBQueryExecutionFixture |
|SqlQuery   |    
|!-SELECT * FROM Articles WHERE ID LIKE <<ArticleNumber-!|

When the Symbol is isolated in a single Cell, everything works fine, but that is not what i need. Example:

// the ArticleNumber-Symbol holds some value and will be evaluated
!| DBQueryExecutionFixture |
|ArticleNum     |    
|<<ArticleNumber|

The SQL-Statement would return many rows, that is why I won´t use the built in query which works fine, but is very unhandy.

Example of built in:

// the ArticleNumber-Symbol holds some value and will be evaluated
| Set parameter | articleNum | <<ArticleNumber |
| Query | !-SELECT * FROM Articles where ID = @articleNum-! |

So, my question is how can I achieve something like the examples at the bottom in the Cells of the ColumnFixture / example at the top?

Kind regards, SirSandmann


Solution

  • As you have noticed, a symbol cannot be embedded inside a cell's content. You can write your own code to handle this, e.g.:

    public class MakeSymbol: SequenceFixture {
        public void Embed(string symbolName, string content, string replacement) {
            Symbols.Save(symbolName, content.Replace("$", replacement));
        }
    }
    

    You could then write a test like this:

    |make symbol|
    |embed|query|!-SELECT * FROM Articles WHERE ID LIKE $-!|<<ArticleNumber|
    
    !| DBQueryExecutionFixture |
    |SqlQuery     |    
    |<<query|