Our cell handler class inherits from fitnesse.handlers.AbstractCellHandler.
using fitnesse.handlers;
public class PiHandler: AbstractCellHandler {
The Match method override determines which cells are processed by our handler. We check for "pi" in the cell and also that we are working with a numeric type. This preserves normal behavior if we're using "pi" as a string input or expected value. public override bool Match(string cellContent, Type type) {
return cellContent != null
&& cellContent == "pi"
&& type == typeof(double));
} Overriding the HandleEvaluate method changes the behavior for expected value cells. We can use the Accessor parameter to get the actual value to compare to "pi". public override bool HandleEvaluate(Fixture fixture, Parse expectedValueCell, Accessor accessor) {
object actual = accessor.Get(fixture);
return actual != null && (double)actual == System.Math.PI;
}Overriding the HandleInput method lets us change the value supplied by input cells. Once again, we use the Accessor parameter to set the input value. public override void HandleInput(Fixture fixture, Parse inputValueCell, Accessor accessor) {
accessor.Set(fixture, System.Math.PI);
}
}