Debian Codegraph @

src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/testtools/micromock/inc/runtimemock.h

raw
1 // Copyright (c) Microsoft. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4 #ifndef RUNTIMEMOCK_H
5 #define RUNTIMEMOCK_H
6
7 #pragma once
8
9 #ifdef _MSC_VER
10 #ifndef DISABLE_DETOURS
11
12 #include "stdafx.h"
13 #include "threadsafeglobalmock.h"
14 #include "detourshookclass.h"
15 #include "mockcallcomparer.h"
16 #include "strictunorderedcallcomparer.h"
17
18 template<class C>
19 class CRuntimeMock : public CThreadSafeGlobalMock<C>,
20 public CDetoursHookClass
21 {
22 public:
23 CRuntimeMock(_In_ AUTOMATIC_CALL_COMPARISON performAutomaticCallComparison = AUTOMATIC_CALL_COMPARISON_ON) :
24 CThreadSafeGlobalMock<C>(performAutomaticCallComparison)
25 {
26 }
27
28 virtual ~CRuntimeMock()
29 {
30 }
31
32 virtual void RegisterFunction(_In_ const void* functionToRegister, _In_ const void* registerFunctionArgument)
33 {
34 // functionToRegister is the mock class member,
35 // registerFunctionArgument should contain the function that should be hooked (detoured)
36 InstallHook(registerFunctionArgument, functionToRegister);
37 }
38
39 virtual void UnregisterFunction(_In_ const void* functionToUnregister, _In_ const void* unregisterFunctionArgument)
40 {
41 // functionToRegister is the mock class member,
42 // registerFunctionArgument should contain the function that should have been hooked (detoured)
43 UninstallHook(unregisterFunctionArgument, functionToUnregister);
44 }
45 };
46
47 #endif // DISABLE_DETOURS
48 #endif // _MSC_VER
49
50 #endif // RUNTIMEMOCK_H