I am trying to write unit test for a simple factory class that creates one of several possible implementation objects and returns it as an interface reference.
DUnit has a built-in procedure CheckIs(AObject: TObject; AClass: TClass; msg: string)
that, based on its name and the parameters that it accepts, should test fail if the class type of the object does not match the expected one. The only problem is that it requires an object reference, not an interface reference.
So, I am trying to use CheckTrue
and perform the comparison in the body of the test, but I am not so familiar with the support of validation like Delphi, since I am from C #.
I know that the operator is is
out of the question, since it only works with object references.
CheckTrue(LMyInterfaceReference {comparison here} TMyClass);
Any suggestions?
By the way, I use Delphi 2009, so I do not have access to the new RTTI support added in 2010.
source
share