Skip to content

Mock of regular methods (functions and procedures) #151

@vampirsoft

Description

@vampirsoft

It would be nice to be able to mock regular methods (functions and procedures). This will allow you to intercept, for example, functions from the Winapi.Windows module, which will make testing much easier.

Example

type
  TSaveDC = function SaveDC(DC: HDC): Integer; stdcall;

const SaveDCMock = TMock<TSaveDC>.Create(Winapi.Windows.SaveDC);

SaveDCMock
  .Setup
  .WillReturn(9)
  .When(It0.IsEqualTo<HDC>(199));
SaveDCMock
  .Setup
  .Expect
  .One
  .When(It0.IsEqualTo<HDC>(199));

const Index = Winapi.Windows.SaveDC(119);

SaveDCMock.Verify // Error, because invalid param
Assert.AreEqual(9, Index);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions