MockCommon.expectCalled

Used to assert function call once

  1. void expectCalled(auto ref V values)
    mixin template MockCommon()
    void
    expectCalled
    (
    string functionName
    string message = null
    string file = __FILE__
    size_t line = __LINE__
    V...
    )
    (
    auto ref V values
    )
  2. void expectCalled(auto ref V values)

Parameters

functionName

The name of expected function.

message

Exception message.

file

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

line

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

values
Type: V

Are expected parameter values.

Throws

If function is not call with parameters, will throw an UnitTestException.

Examples

1 interface Dummy
2 {
3   void test();
4   void test(int a);
5 }
6 
7 auto mock = new Mock!Dummy;
8 mock.test();
9 mock.test(12);
10 mock.expectCalled!"test"();
11 mock.expectCalled!"test"(12);
12 
13 // Will throw an exception like "UnitTestException@example.d(6): <test> expected call with <50> but called with <Tuple!int(12)>
14 mock.exceptCalled!"test"(50);

Meta