shouldBeInstanceOf

Used to assert that object is instance of class.

void
shouldBeInstanceOf
(
T
U
)
(
,
in string message = null
,
in string file = __FILE__
,
in size_t line = __LINE__
)

Parameters

T

Excepted instance class.

object
Type: U

The object it should be instance of specific class.

message
Type: string

The exception message.

file
Type: string

The file name that the assert failed in. Should be left as default.

line
Type: size_t

The file line that the assert failed in. Should be left as default.

Throws

If object is not instance of class, will throw an UnitTestException.

Examples

1 interface DummyInterface
2 {
3   public:
4     void test();
5 }
6 
7 class Dummy: DummyInterface
8 {
9   public:
10     override test()
11     {
12     }
13 }
14 
15 auto a = new Dummy;
16 auto b = cast(DummyInterface) a;
17 b.shouldBeInstanceOf!Dummy();

Meta