I wonder is anyone have tryed using Grensesnitt for unit-testing of classes that all follow the same interface. I have a problem with classes that don’t have parameterless constructors. I know there is GrensesnittObjectLocator but I can’t figure out, how to use it.
Please advice, how to test these classes that don’t have parameterless constructors with grensesnitt.
I didn’t manage to make this working out of the box. I had to tweak it a little. So inside the
GrensesnittObjectLocator.GetHandlermethod instead of:I modified it to:
With this modification in place I wrote the following exmaple:
You can see how the
Fooclass doesn’t have a default constructor. So now we can have this test:And in order to indicate to
grensesnitthow to instantiateFoosimply add the following class to your test assembly (the same assembly that contains the previous unit test):